The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::FormValidator::Results - Object which contains the results of an input validation.

SYNOPSIS

        my $results = Data::FormValidator->check(\%input_hash, \%dfv_profile);

    # Print the name of missing fields
    if ( $results->has_missing ) {
        foreach my $f ( $results->missing ) {
            print $f, " is missing\n";
        }
    }

    # Print the name of invalid fields
    if ( $results->has_invalid ) {
        foreach my $f ( $results->invalid ) {
            print $f, " is invalid: ", $results->invalid( $f ) \n";
        }
    }

    # Print unknown fields
    if ( $results->has_unknown ) {
        foreach my $f ( $results->unknown ) {
            print $f, " is unknown\n";
        }
    }

    # Print valid fields
    foreach my $f ( $results->valid() ) {
        print $f, " =  ", $result->valid( $f ), "\n";
    }

DESCRIPTION

This is the object returned by the Data::FormValidator check method. It can be queried for information about the validation results.

valid( [field], [value] );

This method returns in an array context the list of fields which contains valid value. In a scalar context, it returns an hash reference which contains the valid fields and their value.

If called with one argument, it returns the value of that field if it contains valid data, undef otherwise.

If called with two arguments, the first is taken as a field in the valid hash, and this field is set to the value of the second argument. The value is returned.

This can be useful in some cases to call from within a constraint to alter the results of the valid hash.

has_missing()

This method returns true if the results contains missing fields.

missing( [field] )

This method returns in an array context the list of fields which are missing. In a scalar context, it returns an array reference to the list of missing fields.

If called with an argument, it returns true if that field is missing, undef otherwise.

has_invalid()

This method returns true if the results contains fields with invalid data.

invalid( [field] )

This method returns in an array context the list of fields which contains invalid value.

In a scalar context, it returns an hash reference which contains the invalid fields as keys, and references to arrays of failed constraints as values.

If called with an argument, it returns the reference to an array of failed constraints for this field.

has_unknown()

This method returns true if the results contains unknown fields.

unknown( [field] )

This method returns in an array context the list of fields which are unknown. In a scalar context, it returns an hash reference which contains the unknown fields and their value.

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

msgs([config parameters])

This method returns a hash reference to error messages. The exact format is determined by parameters in th msgs area of the validation profile, described in the Data::FormValidator documentation.

This method takes one possible parameter, a hash reference containing the same options that you can define in the validation profile. This allows you to seperate the controls for message display from the rest of the profile. While validation profiles may be different for every form, you may wish to format messages the same way across many projects.

Controls passed into the <msgs> method will be applied first, followed by ones applied in the profile. This allows you to keep the controls you pass to msgs as "global" and override them in a specific profile if needed.

SEE ALSO

Data::FormValidator, Data::FormValidator::Filters, Data::FormValidator::Constraints, Data::FormValidator::ConstraintsFactory

AUTHOR

Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> Maintainer: Mark Stosberg <mark@summersault.com>

COPYRIGHT

Copyright (c) 1999,2000 iNsu Innovations Inc. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms as perl itself.