| Data::Verifier::Results - Results of a Data::Verifier |
Data::Verifier::Results - Results of a Data::Verifier
use Data::Verifier;
my $dv = Data::Verifier->new(profile => {
name => {
required => 1,
type => 'Str',
filters => [ qw(collapse trim) ]
}
age => {
type => 'Int';
},
sign => {
required => 1,
type => 'Str'
}
});
my $results = $dv->verify({
name => 'Cory', age => 'foobar'
});
$results->success; # no
$results->is_invalid('name'); # no
$results->is_invalid('age'); # yes
$results->is_missing('name'); # no
$results->is_missing('sign'); # yes
Returns true or false based on if the verification's success.
The values present in the result are the filtered, valid values. These may differ from the ones supplied to the verify method due to either filters or coercions.
Returns the number of valid fields in this Results.
Returns a list of valid field names in the results.
Deletes the specified value from the results.
Get the original value for the specified field.
Get the post-filter value for the specified field.
Returns the value for the specified field. The value may be different from the one originally supplied due to filtering or coercion.
Returns the number of values in this Results.
Returns true if the field is valid.
Returns a list of keys for which we have valid values.
Returns a hash of valid values in the form of name = value>. This is a
convenient method for instantiating Moose objects from your verified data.
Returns true if the specific field is invalid.
Returns a list of invalid field names.
Returns the count of invalid fields in this result.
Returns true if the specified field is missing.
Returns a list of missing field names.
Returns the count of missing fields in this result.
Gets the field object, if it exists, for the name provided.
Sets the field object (you shouldn't be doing this directly) for the name provided.
Data::Verifier uses the MooseX::Storage::Deferred manpage to allow quick and easy
serialization. So a quick call to freeze will serialize this object into
JSON and thaw will inflate it. The only caveat is that we don't serialize
the value attribute. Since coercion allows you to make the result any type
you want, it can't reliably be serialized. Use original value if you are
serializing Result objects and using them to refill forms or something.
my $json = $results->freeze({ format => 'JSON' }); # ... my $results = Data::Verifier::Results->thaw($json, { format => 'JSON' });
Cory G Watson, <gphat at cpan.org>
Copyright 2009 Cold Hard Code, LLC
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
| Data::Verifier::Results - Results of a Data::Verifier |