Provided by: libformvalidator-simple-perl_0.29-1_all bug

NAME

       FormValidator::Simple::Results - results of validation

SYNOPSIS

           my $results = FormValidator::Simple->check( $req => [
               name  => [qw/NOT_BLANK ASCII/, [qw/LENGTH 0 10/] ],
               email => [qw/NOT_BLANK EMAIL_LOOSE/, [qw/LENGTH 0 30/] ],
           ] );

           if ( $results->has_error ) {
               foreach my $key ( @{ $results->error() } ) {
                   foreach my $type ( @{ $results->erorr($key) } ) {
                       print "invalid: $key - $type \n";
                   }
               }
           }

DESCRIPTION

       This is for handling resuls of FormValidator::Simple's check.

       This object behaves like Data::FormValidator's results object, but has some specific
       methods.

CHECK RESULT

       has_missing
           If there are missing values ( failed in validation 'NOT_BLANK' ), this method returns
           true.

               if ( $results->has_missing ) {
                   ...
               }

       has_invalid
           If there are invalid values ( failed in some validations except 'NOT_BLANK' ), this
           method returns true.

               if ( $results->has_invalid ) {
                   ...
               }

       has_error
           If there are missing or invalid values, this method returns true.

               if ( $results->has_error ) {
                   ...
               }

       success
           inverse of has_error

               unless ( $resuls->success ) {
                   ...
               }

ANALYZING RESULTS

   missing
       no argument
           When you call this method with no argument, it returns keys failed 'NOT_BLANK'
           validation.

               my $missings = $results->missing;
               foreach my $missing_data ( @$missings ) {
                   print $missing_data, "\n";
               }
               # -- print out, for example --
               # name
               # email

       key When you call this method with key-name, it returnes true if the value of the key is
           missing.

               if ( $results->missing('name') ) {
                   print "name is empty! \n";
               }

   invalid
       no argument
           When you call this method with no argument, it returns keys that failed some
           validation except 'NOT_BLANK'.

               my $invalids = $results->invalid;
               foreach my $invalid_data ( @$invalids ) {
                   print $invalid_data, "\n";
               }
               # -- print out, for example --
               # name
               # email

       key When you call this method with key-name, it returns names of failed validation.

               my $failed_validations = $results->invalid('name');
               foreach my $validation ( @$failed_validations ) {
                   print $validation, "\n";
               }
               # -- print out, for example --
               # ASCII
               # LENGTH

       key and validation-name
           When you call this method with key-name, it returns false if the value has passed the
           validation.

               if ( $results->invalid( name => 'LENGTH' ) ) {
                   print "name is wrong length! \n";
               }

   error
       This doesn't distinguish 'missing' and 'invalid'. You can use this like 'invalid' method,
       but this consider 'NOT_BLANK' same as other validations.

           my $error_keys = $results->error;

           my $failed_validation = $resuls->error('name');
           # this includes 'NOT_BLANK'

           if ( $results->error( name => 'NOT_BLANK' ) ) {
               print "name is missing! \n";
           }

           if ( $results->error( name => 'ASCII' ) ) {
               print "name should be ascii code! \n";
           }

SEE ALSO

       FormValidator::Simple

AUTHOR

       Lyo Kato <lyo.kato@gmail.com>

COPYRIGHT AND LICENSE

       This library is free software.  You can redistribute it and/or modify it under the same
       terms as perl itself.