Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding dot path syntax tests for validator

  • Loading branch information...
commit e770e04bac5e51bbcd692391d9f00e520c18b438 1 parent e1d1907
@Howard3 Howard3 authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/cases/util/ValidatorTest.php
View
20 tests/cases/util/ValidatorTest.php
@@ -1167,6 +1167,26 @@ public function testValidationWithArrays() {
$this->assertFalse(empty($result));
}
+ public function testValidationDotSyntax() {
+ $rules = array(
+ 'foo.bar' => array('numeric', 'message' => 'fail'),
+ 'foo.baz.dib' => array('email', 'message' => 'fail')
+ );
+ $data = array('foo' => array('bar' => 2, 'baz' => array('dib' => 'blah@blah.com')));
+ $result = Validator::add($data, $rules);
+ $this->assertTrue(empty($result));
+
+ $data['foo']['bar'] = 'a';
+ $expected = array('foo.bar' => array('fail'));
+ $result = Validator::check($data, $rules);
+ $this->assertEqual($expected, $result);
+
+ $data['foo']['baz']['dib'] = 'lithium!';
+ $expected['foo.baz.dib'] = array('fail');
+ $result = Validator::check($data, $rules);
+ $this->assertEqual($expected, $result);
+ }
+
/**
* Tests validating nested fields using dot-separated paths.
*/
Please sign in to comment.
Something went wrong with that request. Please try again.