The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Data::FormValidator::Multi::Results - Provide a multidimensional hash or array of DFVM results

SYNOPSIS

# run the check on the data
my $results = $dfv->check( $data );

if ( ! $results->success ) {
  $c->stash->{json}{errors} = $results->to_json;
  return;
}

# handle valid data

DESCRIPTION

Results of the check performed by Data::FormValidator::Multi

METHODS

success

If this is an array of results, return true if all of the elements in the array are valid.

If DF::Multi found invalid sub elements, return false. Otherwise, return the parent class result of success.

to_json

If this is an array of results, call to_json on each element and return an array of the results. Otherwise, return a data structure that represents the invalid (if any) data in the object.

profile_json

Build a hash with invalid field names as keys and that field's errors as the value. Iterate over the invalid nested objects and call to_json on them.

has_objects

This method returns true if the results contain objects fields.

objects( [field] )

In list context, it returns the list of fields which are objects. In a scalar context, it returns an hash reference which contains the objects fields and their values.

If called with an argument, it returns the value of that field if it is objects, undef otherwise.

SEE ALSO

AUTHOR

Todd Wade <waveright@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Todd Wade.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.