root/lang/perl/FormValidator-LazyWay/trunk/lib/FormValidator/LazyWay/Rule/Object.pm @ 17342

Revision 17342, 0.7 kB (checked in by vkgtaro, 6 years ago)

String#string がなくなったので、とりあえず、つねに真を返すルールと言うことで・・・・・・

Line 
1package FormValidator::LazyWay::Rule::Object;
2
3use strict;
4use warnings;
5use utf8;
6
7sub boolean {
8    my $bool = shift;
9    return 0 unless defined $bool;
10    return $bool =~ /^(0|1)$/ ? 1 : 0 ;
11}
12
13sub regexp {
14    my $text = shift;
15    my $args = shift;
16    die 'please set format' unless $args->{format};
17    return $text =~ m/$args->{format}/ ? 1 : 0 ;
18}
19
20sub true {
21    return 1;
22}
23
241;
25
26=head1 NAME
27
28FormValidator::LazyWay::Rule::Object - オブジェクト
29
30=head1 METHOD
31
32=head2 boolan
33
341 | 0
35
36=head2 regexp
37
38regular expression
39
40 Object#regep
41    format : ^\d+$
42
43=head2 true
44
45always true!
46
47=head1 AUTHOR
48
49Tomoiro Teranishi <tomohiro.teranishi@gmail.com>
50
51=cut
Note: See TracBrowser for help on using the browser.