Valiant::Validator::Confirmation - Checks for a 'confirming' attributes equality.
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'", ] };
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').
confirmation
prefix
NOTE: You don't need to add the confirmation attribute, we inject it for you during validation setup.
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.
This validator supports all the standard shared parameters: if, unless, message, strict, allow_undef, allow_blank.
if
unless
message
strict
allow_undef
allow_blank
Valiant, Valiant::Validator, Valiant::Validator::Each.
See Valiant
To install Valiant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Valiant
CPAN shell
perl -MCPAN -e shell install Valiant
For more information on module installation, please visit the detailed CPAN module installation guide.