Provided by: libcatmandu-perl_1.0700-1_all bug

NAME

       Catmandu::Validator::Simple - Simple Validator for Catmandu

SYNOPSIS

           use Catmandu::Validator::Simple;

           my $validator = Catmandu::Validator::Simple->new(
               handler => sub {
                   $data = shift;
                   return "error" unless $data->{title} =~ m/good title/;
                   return;
               }
           );

           if ( $validator->is_valid($hashref) ) {
               save_record_in_database($hashref);
           } else {
               reject_form($validator->last_errors);
           }

DESCRIPTION

       Catmandu::Validator::Simple can be used for doing simple data validation in Catmandu.

METHODS

   new(handler => \&callback, %options)
       The callback function should take $hashref to a data record as argument.  Should return
       undef if the record passes validation otherwise return an error or an arrayref of errors.
       Each error can be either a simple message string or a hashref to a more detailed error
       information.

       The constructor also accepts the common options for Catmandu::Validator.

   is_valid(...)
   validate(...)
   last_errors(...)
   valid_count()
   invalid_count()
       These are methods are inherited from Catmandu::Validator.

SEE ALSO

       Catmandu::Validator