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

NAME

Validator::Custom::Validation - a result of validation

SYNOPSYS

  my $validation = $vc->validation;
  
  $validation->add_failed(title => 'title is invalid');
  $validation->add_failed(name => 'name is invalid');
  
  # Is valid
  my $is_valid = $validation->is_valid;
  my $title_is_valid = $validation->is_valid('title');
  
  # Get all failed parameter names
  my $failed = $validation->failed;
  
  # Message
  my $messages = $validation->messages;
  my $title_message = $validation->message('title');
  my $messages_h = $validation->messages_to_hash;

METHODS

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

new

  my $validation = Validator::Custom::Validation->new;
  

Create a Validator::Custom::Validation object.

Generally this method is not used. You should use 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 result of validation is valid. If name is specified, check if the parameter corresponding to the name is valid.

add_failed

  $validation->add_failed('title' => 'title is invalid value');
  $validation->add_failed('title');

Add a failed parameter name and message. If message is omitted, default message is set automatically.

failed

  my $failed = $validation->failed;

Get all failed parameter names.

message

  my $message = $validation->message('title');

Get a failed message corresponding to the name.

messages

  my $messgaes = $validation->messages;

Get all failed messages.

messages_to_hash

  my $messages_h = $validation->messages_to_hash;

Get all failed parameter names and messages as hash reference.