1use strict; 2 3package HTML::FormFu::Constraint::Number; 4$HTML::FormFu::Constraint::Number::VERSION = '2.07'; 5# ABSTRACT: Numerical Constraint 6 7use Moose; 8extends 'HTML::FormFu::Constraint'; 9 10use Scalar::Util qw( looks_like_number ); 11 12sub constrain_value { 13 my ( $self, $value ) = @_; 14 15 return 1 if !defined $value || $value eq ''; 16 17 my $ok = looks_like_number($value); 18 19 return $self->not ? !$ok : $ok; 20} 21 22__PACKAGE__->meta->make_immutable; 23 241; 25 26__END__ 27 28=pod 29 30=encoding UTF-8 31 32=head1 NAME 33 34HTML::FormFu::Constraint::Number - Numerical Constraint 35 36=head1 VERSION 37 38version 2.07 39 40=head1 DESCRIPTION 41 42The input must be a number. 43 44=head1 SEE ALSO 45 46Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> 47 48L<HTML::FormFu> 49 50=head1 AUTHOR 51 52Carl Franks C<cfranks@cpan.org> 53 54=head1 LICENSE 55 56This library is free software, you can redistribute it and/or modify it under 57the same terms as Perl itself. 58 59=head1 AUTHOR 60 61Carl Franks <cpan@fireartist.com> 62 63=head1 COPYRIGHT AND LICENSE 64 65This software is copyright (c) 2018 by Carl Franks. 66 67This is free software; you can redistribute it and/or modify it under 68the same terms as the Perl 5 programming language system itself. 69 70=cut 71