/t/lib/Field/AltText.pm
http://github.com/gshank/html-formhandler · Perl · 25 lines · 16 code · 8 blank · 1 comment · 0 complexity · 678bfe053c5435b2d59637e232783936 MD5 · raw file
- package Field::AltText;
- use Moose;
- extends 'HTML::FormHandler::Field::Text';
- has 'another_attribute' => ( isa => 'Str', is => 'rw' );
- sub validate
- {
- my $field = shift;
- return unless $field->SUPER::validate;
- my $input = $field->input;
- my $check = $field->another_attribute;
- # do something silly
- return $field->add_error('Fails AltText validation')
- unless $input =~ m/$check/;
- return 1;
- }
- no Moose;
- 1;