Esempio n. 1
0
 /**
  * Get complete field info as array:
  * [
  *     name => 'example'
  *     value => '10000'
  *     error => 'integer max 100'
  *     validate => [
  *         required => true
  *         rule => integer
  *         options => [max => 100]
  *     ]
  * ]
  * 
  * @param string
  * @return array
  */
 public function getField($name)
 {
     $field = ['name' => $name, 'value' => $this->value($name), 'error' => null, 'validate' => ['rule' => null, 'options' => []], 'form' => $this->name()];
     if (isset($this->errors[$name])) {
         $field['error'] = $this->errors[$name];
     }
     if ($this->validator) {
         $field['validate'] = $this->validator->getFieldRule($name);
     }
     return $field;
 }
Esempio n. 2
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);
 }
Esempio n. 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());
 }