Since: 2.0
Author: Fuel Development Team
Inheritance: implements Fuel\Validation\ResultInterface
Esempio n. 1
0
 public function testMergeWithStatus()
 {
     $result1 = new Result();
     $result1->setResult(true);
     // merging this should cause the $result1 to no longer be valid
     $result2 = new Result();
     $result2->setResult(false);
     $result1->merge($result2);
     $this->assertFalse($result1->isValid());
 }
Esempio n. 2
0
 public function testSetGetValidated()
 {
     $this->object->setValidated('test');
     $this->assertEquals(array('test'), $this->object->getValidated());
 }
Esempio n. 3
0
 /**
  * Takes an array of data and validates that against the assigned rules.
  * The array is expected to have keys named after fields.
  * This function will call reset() before it runs.
  *
  * @param array           $data
  * @param ResultInterface $result
  *
  * @return ResultInterface
  *
  * @since 2.0
  */
 public function run($data, ResultInterface $result = null)
 {
     if ($result === null) {
         $result = new Result();
     }
     $result->setResult(true);
     foreach ($this->fields as $fieldName => $rules) {
         $fieldResult = $this->validateField($fieldName, $data, $result);
         if (!$fieldResult) {
             // There was a failure so log it to the result object
             $result->setResult(false);
         }
     }
     return $result;
 }