GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  VALIDATOR::CUSTOM::RULE (3)

.ds Aq ’

NAME

Validator::Custom::Rule - Rule object

CONTENTS

SYNOPSYS



  use Validator::Custom;
  my $vc = Validator::Custom->new;
 
  # Create rule object
  my $rule = $vc->create_rule;
  $rule->require(id)->check(
    ascii
  );
  $rule->optional(name)->check(
   not_blank
  );
 
  # Validate
  my $data = {id => 001, name => kimoto};
  my $result = $vc->validate($data, $rule);
 
  # Option
  $rule->require(id)->default(4)->copy(0)->message(Error)->check(
    not_blank
  );



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

    each



  $rule->each(1);



Tell checke each element.

    check



  $rule->check(not_blank)->check(ascii);



Add constraints to current topic.

    check_or



  $rule->check_or(not_blank, ascii);



Add or condition constraints to current topic.

    copy



  $rule->copy(0);



Set copy option

    default



  $rule->default(0);



Set default option

    filter



  $rule->filter(trim);



This is check method alias for readability.

    message



  $rule->require(name)
    ->check(not_blank)->message(should be not blank)
    ->check(int)->message(should be int);



Set message for each check.

Message is fallback to before check so you can write the following way.



  $rule->require(name)
    ->check(not_blank)
    ->check(int)->message(should be not blank and int);



    name



  $rule->name(key1);



Set result key name

    optional



  $rule->optional(id);



Set key and set require option to 0.

    require



  $rule->require(id);
  $rule->require([id1, id2]);



Set key.

    parse



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



Parse rule and store it to rule attribute.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 VALIDATOR::CUSTOM::RULE (3) 2015-05-30

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.