NAME
Spark::Form::Field::Role::Validateable - Fields that can be validated.
SYNOPSIS
package MyApp::Field::CustomText;
use Moose;
extends 'Spark::Form::Field';
with 'Spark::Form::Field::Role::Validateable';
sub validate {
my $self = shift;
if ($self->value eq 'password') {
$self->valid(1);
return 1;
} else {
$self->error('password is password');
return 0;
}
}
ACCESSORS
valid => Bool
Treat as readonly. Whether the field is valid.
errors => ArrayRef
Treat as readonly. The list of errors generated in validation.
METHODS
error (Str)
Adds an error to the current field's list.
INTERFACE
To be considered validateable, you must implement this role.
It requires the following methods:
validate
This should take value and set valid to 1 or call error. It should also return valid.