Example #1
0
 /**
  * Test the regexp validation
  *
  * @return void
  * @author Dan Cox
  */
 public function test_regexpValidation()
 {
     $field = new Field('rule', 'text', NULL, '', [new Validation\RegexValidation('Custom regex message', '/[A-Za-z]{1,}/')], '', array(), array('rule' => ''));
     $field2 = new Field('rule2', 'text', NULL, '', [new Validation\RegexValidation(null, '/[A-Za-z]{1,}/')], '', array(), array('rule2' => 'abc'));
     $field3 = new Field('rule3', 'text', NULL, '', [new Validation\RegexValidation()]);
     $field->validate();
     $field2->validate();
     $field3->validate();
     $error = $field->errors()[0];
     $this->assertEquals('Custom regex message', $error);
     $this->assertEquals(0, count($field2->errors()));
     $this->assertEquals(0, count($field3->errors()));
 }