NAME

Validator::Custom::Rule - Rule object (EXPERIMENTAL)

SYNOPSYS

# Create rule object and parse rule
my $rule_obj = Validator::Custom::Rule->new;
my $rule = [
  id => [
    'ascii'
  ],
  name => [
    'not_blank'
  ]
]
$rule_obj->parse($rule);

# Pass rule object to validate method
my $vc = Validator::Custom->new;
my $data = {id => '001', name => 'kimoto'};
my $result = $vc->validate($data, $rule_obj);

# Usual way is shortcut of above
my $result2 = $vc->validate($date, $rule);

DESCRIPTION

Validator::Custom::Rule is the class to parse rule and store it as object.

ATTRIBUTES

rule

my $content = $rule_obj->rule;
$rule_obj = $rule->rule($content);

Content of rule object.

METHODS

parse

$rule_obj = $rule_obj->parse($rule);

Parse rule and store it to rule attribute.