NAME

Valiant::Validator::Confirmation - Checks for a 'confirming' attributes equality.

SYNOPSIS

    package Local::Test::Confirmation;

    use Moo;
    use Valiant::Validations;

    has email=> (is=>'ro');

    validates email => ( confirmation => 1 );

    my $object = Local::Test::Confirmation->new(
      email => 'AAA@example.com',
      email_confirmation => 'ZZZ@example.com'
    );
    $object->validate;

    warn $object->errors->_dump;

    $VAR1 = {
      'email_confirmation' => [
        "Email confirmation doesn't match 'Email'",
      ]
    };

DESCRIPTION

Use this when you have two attributes which should be set to the same value (for example to confirm someone entered the correct email address or changed their password to the same value).

The error message (if any) will appear associated with the confirmation attribute. Error message uses tag confirmation and you can override that with an init arg of the same name. You can also change the prefix used to identify the confirming attribute with the prefix init arg (default value is '_confirmation').

NOTE: You don't need to add the confirmation attribute, we inject it for you during validation setup.

SHORTCUT FORM

This validator supports the follow shortcut forms:

    validates attribute => ( confirmation => 1, ... );

Which is the same as:

    validates attribute => (
      confirmation => +{},
    );

Not a lot of saved typing but it seems to read better.

GLOBAL PARAMETERS

This validator supports all the standard shared parameters: if, unless, message, strict, allow_undef, allow_blank.

SEE ALSO

Valiant, Valiant::Validator, Valiant::Validator::Each.

AUTHOR

See Valiant

COPYRIGHT & LICENSE

See Valiant