PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1package Field::AltText;
 2
 3use Moose;
 4extends 'HTML::FormHandler::Field::Text';
 5
 6
 7has 'another_attribute' => ( isa => 'Str', is => 'rw' );
 8
 9sub validate
10{
11   my $field = shift;
12
13   return unless $field->SUPER::validate;
14
15   my $input = $field->input;
16   my $check = $field->another_attribute;
17   # do something silly
18   return $field->add_error('Fails AltText validation')
19       unless $input =~ m/$check/;
20
21   return 1;
22}
23
24no Moose;
251;