Esempio n. 1
0
 /**
  * testGetRules method
  *
  * @return void
  */
 public function testGetRules()
 {
     $field = new ValidationSet();
     $field->add('notBlank', ['rule' => 'notBlank', 'message' => 'Can not be empty']);
     $result = $field->rules();
     $this->assertEquals(['notBlank'], array_keys($result));
     $this->assertInstanceOf('Cake\\Validation\\ValidationRule', $result['notBlank']);
 }
Esempio n. 2
0
 /**
  * Sets the rule set for a field
  *
  * @param string $field name of the field to set
  * @param array|\Cake\Validation\ValidationSet $rules set of rules to apply to field
  * @return void
  */
 public function offsetSet($field, $rules)
 {
     if (!$rules instanceof ValidationSet) {
         $set = new ValidationSet();
         foreach ((array) $rules as $name => $rule) {
             $set->add($name, $rule);
         }
     }
     $this->_fields[$field] = $rules;
 }