|
NAMEValidator::Custom::Result - Result of validationSYNOPSYS# Result my $result = $vc->validate($data, $rule); # Safety data my $safe_data = $result->data; # Chacke if the result is valid. # (this means result have neither missing nor invalid parameter) my $is_ok = $result->is_ok; # Check the existence of missing parameter my $has_missing_param = $result->has_missing; # 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; # Result to hash my $rhash = $result->to_hash; # Raw data my $raw_data = $result->raw_data; ATTRIBUTESdatamy $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_paramsmy $missing_params = $result->missing_params; $result = $result->missing_params($missing_params); You can get missing parameter names using "missing_params()". In this example, return value is the following one. raw_datamy $data = $result->raw_data; $result = $result->raw_data($data); Raw data soon after data_filter is executed. METHODSValidator::Custom::Result inherits all methods from Object::Simple and implements the following new ones.has_invalidmy $has_invalid = $result->has_invalid; If at least one of parameter value is invalid, "has_invalid()" return true value. has_missingmy $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_paramsmy $invalid_params = $result->invalid_params; Invalid raw data parameter names. invalid_rule_keysmy $invalid_rule_keys = $result->invalid_rule_keys; Invalid rule keys is_okmy $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_validmy $title_is_valid = $result->is_valid('title'); Check if one parameter is valid. loose_datamy $loose_data = $result->loose_data; Loose data, which is data merged "raw_data" and "data" # Loose data {%{$self->raw_data}, %{$self->data}} messagemy $message = $result->message('title'); Get a message corresponding to the parameter name which value is invalid. messagesmy $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_hashmy $messages = $result->messages_to_hash; You can get the pairs of invalid parameter name and message using "messages_to_hash()". to_hashmy $rhash = $result->to_hash; Convert result information to hash reference. The following keys is set. { ok => $result->is_ok, missing => $result->has_missing, invalid => $result->has_invalid, missing_params => $result->missing_params, messages => $result->messages_to_hash }
Visit the GSP FreeBSD Man Page Interface. |