Data::Verifier::Results - Results of a Data::Verifier verify
version 0.51
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
Data::Verifier uses MooseX::Storage::Deferred 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.
freeze
thaw
value
my $json = $results->freeze({ format => 'JSON' }); # ... my $results = Data::Verifier::Results->thaw($json, { format => 'JSON' });
This module has a hashref attribute fields. The keys are the names of the fields from the profile. The keys are are either undef or a Data::Verifier::Field object.
fields
undef
The only keys that will be populated in the Result object are those that were listed in the profile. Any arbitrary fields will not be part of the result object, as they were not part of the profile. You should not query the result object for the state of any arbitrary fields. This will not throw any exceptions, but it may not return the results you want if you query for arbitrary field names.
HashRef of fields in this Results object.
Gets the field object, if it exists, for the name provided.
Returns true if the name in question is part of this result object. This should be true for any field that was in the profile.
Sets the field object (you shouldn't be doing this directly) for the name provided.
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.
Same concept as get_value but will return a list of respective values in the same order in which you provide the names.
get_value
Returns true if the specific field is invalid.
Returns true if the specified field is missing.
Returns true if the field is valid.
Returns true if the value was required and is missing or if the value did not pass it's type constraint. This is a one-stop method for determining if the field in question is "wrong".
Merge an existing Data::Verifier::Results object into this one.
Returns the count of invalid fields in this result.
Returns a list of invalid field names.
Returns the count of missing fields in this result.
Returns a list of missing field names.
Returns true or false based on if the verification's success.
Returns a list of keys for which we have valid values.
Returns the number of valid fields in this Results.
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.
name =
Cory G Watson <gphat@cpan.org>
This software is copyright (c) 2012 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Verifier, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Verifier
CPAN shell
perl -MCPAN -e shell install Data::Verifier
For more information on module installation, please visit the detailed CPAN module installation guide.