Skip to content

Instantly share code, notes, and snippets.

@TristinDavis
Created November 16, 2012 01:40
Show Gist options
  • Save TristinDavis/4083150 to your computer and use it in GitHub Desktop.
Save TristinDavis/4083150 to your computer and use it in GitHub Desktop.
Validation-Class Basics
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