Valiant::Filter::Each - A Role to create custom validators
package Valiant::Filter::With; use Moo; with 'Valiant::Filter::Each'; has cb => (is=>'ro', required=>1); sub normalize_shortcut { my ($class, $arg) = @_; if((ref($arg)||'') eq 'CODE') { return +{ cb => $arg, }; } } sub filter_each { my ($self, $class, $attrs, $attribute_name) = @_; return $self->cb->($class, $attrs, $attribute_name); } 1;
Use this role when you with to create a custom filter that will be run on your class attributes. Please note that you can also use the 'with' validator (Valiant::Filter::With) for simple custom filter needs. Its best to use this role when you want custom filters that is going to be shared across several classes so the effort pays off in reuse.
Your class must provide the method filter_each, which will be called once for each attribute in the validation.
filter_each
Valiant, Valiant::Filter.
See Valiant
To install Valiant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Valiant
CPAN shell
perl -MCPAN -e shell install Valiant
For more information on module installation, please visit the detailed CPAN module installation guide.