File: AltText.pm

package info (click to toggle)
libhtml-formhandler-perl 0.40068-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 2,484 kB
  • sloc: perl: 9,416; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 436 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;