Esempio n. 1
0
 public function test_validate_with_no_rule()
 {
     $validator = new Validation();
     $rules = ['no_rule' => []];
     $validator->make($rules);
     $validator->validate(['no_rule' => '05052016']);
     $this->assertTrue($validator->isValid());
 }
Esempio n. 2
0
 /**
  * Registry constructor.
  *
  * @param array $fields
  *
  */
 public function __construct(array $fields = [])
 {
     $this->validator = new Validation();
     $this->validator->make($this->defaultFields);
     $this->fill();
     foreach ($fields as $field => $value) {
         if (array_key_exists($field, $this->defaultFields) === false) {
             throw new FieldNotExistsException($field);
         }
         $this->values[$field]->setValue($value);
     }
     try {
         $this->validator->validate($fields);
     } catch (\Convenia\AleloOrder\Exceptions\RegistryTooShortException $e) {
         new RegistryTooShortException($e->getMessage() . 'in registry ' . get_class());
     }
     $this->generate();
     $this->validateLength();
 }