/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

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