Validation logic is more complex than you expect
I am creating Validator::Custom from 2009. This is a validation module.
I add many features to customize validation but I can't solve many problems because Validation logic is more complex than I expect.
Mojolicious remove filter feature of validation module. It is maybe impossible to do three things(require, checking, filtering) at once.
And validation logic is complex because we want to see multiple values at once. for example, "high_price" param + "low_price" param.
Next, In html validation, we must think about fore cases.
4. (not exists)
And We want do filtering for blank containing value, for example, " Kimoto ".
And We maybe want to prepare default value when validation fail.
Above combination is very very complex.
Conclusion is that simple is best
At first programmer must to choice a value or values. By this, we don't need to thing "require" checking.
# A value my $age = $c->param('age');
my $features = $c->every_param('features');
After that, you do filtering and checking.
$age = $vc->filter($age, 'trim'); # " 12 " to "12" my $age_is_valid = $vc->check($age, 'int');
$features = $vc->filter($features, 'remove_blank'); # ['', '001', '002'] to ['001', '002']
my $features_is_valid = $vc->check_each($features, 'in', ['001', '002', '003']]);