FormVa...esults(3pm)
πΈ NAME πΈ
FormValidator::Simple::Results β the results of validation. that's the whole plot bestie π
β¨ 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";
}
}
}
look at that little check-and-loop moment, it's giving "I check my forms and I know things" energy π
π¦ DESCRIPTION π¦
okay so this whole module exists to handle the results that come out of FormValidator::Simple's check. that's it, that's the job.
the object behaves like Data::FormValidator's results object, but it has some specific methods of its own. so like, same vibe, extra sauce. π
π CHECK RESULT π
has_missing
if there are missing values β meaning something failed the NOT_BLANK validation β this method returns true. fr fr.
if ( $results->has_missing ) {
...
}
has_invalid
if there are invalid values β meaning something failed some validation except NOT_BLANK β this method returns true.
if ( $results->has_invalid ) {
...
}
has_error
if there are missing values or invalid values, this method returns true. it's the "any drama at all?" detector π
if ( $results->has_error ) {
...
}
success
the inverse of has_error. no cap.
unless ( $resuls->success ) {
...
}
π«Ά yes the variable in that snippet is spelled $resuls. we do not fix the sacred texts, bestie. copy it exactly.
π ANALYZING RESULTS π
missing
- no argument β call it with nothing and it returns the keys that failed
NOT_BLANKvalidation.
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 a key-name, it returns true if the value of that key is missing.
if ( $results->missing('name') ) {
print "name is empty! \n";
}
invalid
- no argument β call it with nothing and it returns the 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 a key-name, it returns the names of the failed validations.
my $failed_validations = $results->invalid('name');
foreach my $validation ( @$failed_validations ) {
print $validation, "\n";
}
# -- print out, for example --
# ASCII
# LENGTH
keyand validation-name β when you call this method with a 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 one doesn't distinguish between missing and invalid. you can use it like the invalid method, but it treats NOT_BLANK the same as every other validation. one big happy error pile π
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 β go read that one too, it's the main character here π
π 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.
and that's a wrap, bestie π«Ά this page shipped as part of perl v5.34.0, dated 2022-06-14, and it lives in the User Contributed Perl Documentation section of your friendly neighborhood man pages. go validate something and slay β¨π
π¦ where this page comes from
- debian bookworm: libformvalidator-simple-perl 0.29-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libformvalidator-simple-perl 0.29-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libformvalidator-simple-perl 0.29-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libformvalidator-simple-perl 0.29-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libformvalidator-simple-perl 0.29-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms