FormValidator::LazyWay::Rule::Object - object


FormValidator-LazyWay documentation Contained in the FormValidator-LazyWay distribution.

Index


Code Index:

NAME

Top

FormValidator::LazyWay::Rule::Object - object

METHOD

Top

boolean

1 | 0

regexp

regular expression

 Object#regexp
    format : ^\d+$

true

always true!

AUTHOR

Top

Tomohiro Teranishi <tomohiro.teranishi@gmail.com>


FormValidator-LazyWay documentation Contained in the FormValidator-LazyWay distribution.

package FormValidator::LazyWay::Rule::Object;

use strict;
use warnings;
use utf8;

sub boolean {
    my $bool = shift;
    return 0 unless defined $bool;
    return $bool =~ /^[01]$/ ? 1 : 0 ;
}

sub regexp {
    my $text = shift;
    my $args = shift;
    die 'please set format' unless $args->{format};
    return $text =~ m/$args->{format}/ ? 1 : 0 ;
}

sub true {
    return 1;
}

1;
__END__