Пример #1
0
 /**
  * Create Form instance with current DI Container.
  * 
  * @param \Vero\Validate\Container
  * @param array|null
  * @return Validator
  */
 public function validator($vfc = null, $fields = null)
 {
     return Validator::create($this->get('request'), $vfc, $fields);
 }
Пример #2
0
 /**
  * Set form instance Validator.
  * 
  * @param Validator|VFC
  * @param array|null
  * @return self
  */
 public function setValidator($validator, $fields = null)
 {
     if (!$validator instanceof Validator && !$validator instanceof VFC) {
         throw new \InvalidArgumentException('Validator set for Form must be instance of \\Vero\\Validate\\Validator or \\Vero\\Validate\\Container!');
     }
     if ($validator instanceof VFC) {
         $validator = Validator::create($this->request, $validator, $fields);
     }
     $this->validator = $validator;
     return $this;
 }
Пример #3
0
 public function testArraySet()
 {
     $data = array('correct1' => ['a', 'b'], 'incorrect1' => 'a');
     $items1 = array('a' => 'A', 'b' => 'B');
     $this->assertTrue(V::create($data)->map('correct1', 'array', array('rule' => 'set', 'options' => array('items' => $items1)))->isValid());
     //$this->assertFalse(V::create($data)->map('incorrect1', 'array', array('rule'=>'set','options'=>array('items'=>$items1)))->isValid());
 }