++ed by:

2 non-PAUSE users.

Yuki Kimoto

NAME

Validator::Custom::Result - Result of validation

SYNOPSYS

    # Result
    my $result = $vc->validate($data, $rule);
    
    # Check the existence of missing parameter
    my $has_missing_param = $result->has_missing;

    # Chack if the data has invalid parameter(except for missing parameter)
    my $has_invalid = $resutl->has_invalid;
    
    # Chacke if the result is valid.
    # (this means result have neither missing nor invalid parameter)
    my $is_ok = $result->is_ok;
    
    # Check if one parameter is valid
    my $title_is_valid = $result->is_valid('title');

    # Missing parameters(this is original keys)
    my $missing_params = $result->missing_params;
    
    # Invalid parameter names(this is original keys)
    my $invalid_params = $result->invalid_params;
    
    # Invalid rule keys
    my $invalid_rule_keys = $result->invalid_rule_keys;

    # A error message
    my $message = $result->message('title');

    # Error messages
    my $messages = $result->messages;

    # Error messages to hash ref
    my $messages_hash = $result->message_to_hash;
    
    # Raw data
    my $raw_data = $result->raw_data;
    
    # Result data
    my $result_data = $result->data;

ATTRIBUTES

data

    my $data = $result->data;
    $result  = $result->data($data);

Get the data in the end state. Validator::Custom has filtering ability if you need. The data passed to validate() is converted to other data by filter. You can get filtered data using data().

missing_params

    my $missing_params = $result->missing_params;
    $result            = $result->missing_params($missing_params);

You can get missing paramter names using missing_params(). In this example, return value is the following one.

raw_data

    my $data  = $result->raw_data;
    $result   = $result->raw_data($data);

Raw data soon after data_filter is excuted.

METHODS

Validator::Custom::Result inherits all methods from Object::Simple and implements the following new ones.

error_reason

    $error_reason = $result->error_reason('title');

Error reason. This is constraint name.

has_invalid

    my $has_invalid = $result->has_invalid;

If at least one of parameter value is invalid, has_invalid() return true value.

has_missing

    my $has_missing_param = $result->has_missing;

If at least one of parameter names specified in the rule is not found in the data, has_missing() return true value.

invalid_params

    $invalid_params = $result->invalid_params;

Invalid raw data parameter names.

invalid_rule_keys

    $invalid_rule_keys = $result->invalid_rule_keys;

Invalid rule keys

is_ok

    $is_ok = $result->is_ok;

If you check the data is completely valid, use is_ok(). is_ok() return true value if invalid parameter values is not found and all parameter names specified in the rule is found in the data.

is_valid

    my $title_is_valid = $result->is_valid('title');

Check if one paramter is valid.

message

    $message = $result->message('title');

Get a message corresponding to the parameter name which value is invalid.

messages

    $messages = $result->messages;

Get messages corresponding to the parameter names which value is invalid. Messages keep the order of parameter names of the rule.

messages_to_hash

    $messages = $result->messages_to_hash;

You can get the pairs of invalid parameter name and message using messages_to_hash().