addInstanceRule() public method

Adds a new validation rule callback that is tied to the current instance only.
public addInstanceRule ( string $name, mixed $callback, string $message = null )
$name string
$callback mixed
$message string
コード例 #1
0
 public function testUniqueRuleName()
 {
     $v = new Validator(array());
     $args = array("foo", "bar");
     $this->assertEquals("foo_bar_rule", $v->getUniqueRuleName($args));
     $this->assertEquals("foo_rule", $v->getUniqueRuleName("foo"));
     $v->addInstanceRule("foo_rule", function () {
     });
     $u = $v->getUniqueRuleName("foo");
     $this->assertRegExp("/^foo_rule_[0-9]{1,5}\$/", $u);
 }