| 1 | package HTML::Widget::JavaScript::Constraint::Length; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use base 'HTML::Widget::Constraint::Length'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | HTML::Widget::JavaScript::Constraint::Length - JavaScript Length Constraint | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.02 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 2 | our $VERSION = '0.02'; | |||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | JavaScript Length Constraint. | ||||||||||
| 23 | |||||||||||
| 24 | =head1 METHODS | ||||||||||
| 25 | |||||||||||
| 26 | See L<HTML::Widget::Constraint::Length>. | ||||||||||
| 27 | |||||||||||
| 28 | =head2 $self->emit_javascript($var_name) | ||||||||||
| 29 | |||||||||||
| 30 | Emits this constraint's JavaScript validation code. | ||||||||||
| 31 | |||||||||||
| 32 | =cut | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub emit_javascript { | ||||||||
|
Subroutine
emit_javascript: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 35 | 0 | my ($self, $var_name) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 0 | my $min = $self->minimum; | |||||||||
| 38 | 0 | my $max = $self->maximum; | |||||||||
| 39 | |||||||||||
| 40 | 0 | my $msg = $self->message; | |||||||||
| 41 | |||||||||||
| 42 | 0 | my @js_constraints; | |||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | my $not = $self->not ? '!' : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | for my $param (@{$self->names}) { | |||||||||
| 47 | 0 | ▶ | if ($min) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | push(@js_constraints, "$not (${var_name}.${param}.value.length < $min)"); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | if ($max) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | push(@js_constraints, "$not (${var_name}.${param}.value.length > $max)"); | |||||||||
| 53 | } | ||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | return @js_constraints; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | =head1 AUTHOR | ||||||||||
| 60 | |||||||||||
| 61 | Nilson Santos Figueiredo Júnior, C<< <nilsonsfj at cpan.org> >> | ||||||||||
| 62 | |||||||||||
| 63 | =head1 BUGS | ||||||||||
| 64 | |||||||||||
| 65 | Please report any bugs or feature requests directly to the author. | ||||||||||
| 66 | If you ask nicely it will probably get fixed or implemented. | ||||||||||
| 67 | |||||||||||
| 68 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 69 | |||||||||||
| 70 | Copyright 2006, 2009 Nilson Santos Figueiredo Júnior, all rights reserved. | ||||||||||
| 71 | |||||||||||
| 72 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 73 | under the same terms as Perl itself. | ||||||||||
| 74 | |||||||||||
| 75 | =cut | ||||||||||
| 76 | |||||||||||
| 77 | 2 | 1; # End of HTML::Widget::JavaScript::Constraint | |||||||||