Validator::Custom::Validation - Validation result
Name
Validator::Custom::Validation - Validation result
How to use
my $validation = $vc->validation; $validation->add_failed(title =>'title is invalid'); $validation->add_failed(name =>'name is invalid'); # Is it correct my $is_valid = $validation->is_valid; my $title_is_valid = $validation->is_valid('title'); # Name of failed parameter my $failed = $validation->failed; # message my $messages = $validation->messages; my $title_message = $validation->message('title'); my $messages_h = $validation->messages_to_hash;
=====
Method
Validator::Custom::Validation is all methods from Object::Simple It inherits from and implements the following new methods:
new
my $validation = Validator::Custom::Validation->new;
Create a new Validator::Custom::Validation object.
Generally this method is not used. It's a good idea to use the validation method of Validator::Custom.
my $validation = $vc->validation;
is_valid
my $is_valid = $validation->is_valid; my $is_valid = $validation->is_valid('title');
Check if the validation result is correct. If given a name, it checks if the parameters corresponding to that name are correct.
add_failed
$validation->add_failed('title' =>'title is invalid value'); $validation->add_failed('title');
Add the name and message of the failed parameter. If the message is omitted, the default message will be set automatically.
failed
my $failed = $validation->failed;
Gets the names of all failed parameters.
message
my $message = $validation->message('title');
Gets the failure message that corresponds to the name.
messages
my $messgaes = $validation->messages;
Get all failure messages.
messages_to_hash
my $messages_h = $validation->messages_to_hash;
Gets all failed parameter names and messages as a hash reference.