| 1 | package HTML::FormHandler::Field::PosInteger; | ||
| 2 | # ABSTRACT: positive integer field | ||
| 3 | 3 | $HTML::FormHandler::Field::PosInteger::VERSION = '0.410001'; | |
| 4 | 3 | ▶ | use HTML::FormHandler::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | extends 'HTML::FormHandler::Field::Integer'; | |
| 6 | |||
| 7 | 3 | our $class_messages = { | |
| 8 | 'integer_positive' => 'Value must be a positive integer', | ||
| 9 | }; | ||
| 10 | |||
| 11 | sub get_class_messages { | ||
| 12 | 12 | ▶ | my $self = shift; |
|
Subroutine
get_class_messages: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 13 | return { | ||
| 14 | 12 | %{ $self->next::method }, | |
| 15 | %$class_messages, | ||
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 | apply( | ||
| 20 | [ | ||
| 21 | { | ||
| 22 | 7 | ▶ | check => sub { $_[0] >= 0 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 23 | message => sub { | ||
| 24 | 4 | ▶ | my ( $value, $field ) = @_; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 25 | 4 | return $field->get_message('integer_positive'); | |
| 26 | }, | ||
| 27 | } | ||
| 28 | 3 | ] | |
| 29 | ); | ||
| 30 | |||
| 31 | |||
| 32 | 3 | __PACKAGE__->meta->make_immutable; | |
| 33 | 3 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 34 | 3 | 1; | |
| 35 | |||
| 36 | __END__ | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =encoding UTF-8 | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | HTML::FormHandler::Field::PosInteger - positive integer field | ||
| 45 | |||
| 46 | =head1 VERSION | ||
| 47 | |||
| 48 | version 0.410001 | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | Tests that the input is an integer and has a positive value. | ||
| 53 | |||
| 54 | Customize error message 'integer_positive'. | ||
| 55 | |||
| 56 | =head1 AUTHOR | ||
| 57 | |||
| 58 | FormHandler Contributors - see HTML::FormHandler | ||
| 59 | |||
| 60 | =head1 COPYRIGHT AND LICENSE | ||
| 61 | |||
| 62 | This software is copyright (c) 2017 by Gerda Shank. | ||
| 63 | |||
| 64 | This is free software; you can redistribute it and/or modify it under | ||
| 65 | the same terms as the Perl 5 programming language system itself. | ||
| 66 | |||
| 67 | =cut | ||