Created
November 16, 2012 01:40
-
-
Save TristinDavis/4083153 to your computer and use it in GitHub Desktop.
Validation-Class Basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp::Validation; | |
use Validation::Class; | |
use base 'Validation::Class'; | |
# a validation rule | |
field 'login' => { | |
label => 'user login', | |
error => 'login invalid', | |
validation => sub { | |
my ($self, $this, $fields) = @_; | |
return $this->{value} eq 'admin' ? 1 : 0; | |
} | |
}; | |
# a validation rule | |
field 'password' => { | |
label => 'user password', | |
error => 'password invalid', | |
validation => sub { | |
my ($self, $this, $fields) = @_; | |
return $this->{value} eq 'pass' ? 1 : 0; | |
} | |
}; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment