Пример #1
0
 /**
  * @return \Nano\Form
  * @param string $field
  * @param \Nano\Validator $validator
  * @param string $message
  *
  * @throws \Nano\Exception
  */
 public function addValidator($field, \Nano\Validator $validator, $message = null)
 {
     $this->invalidate();
     if (isset($this->validators[$field])) {
         throw new \Nano\Exception('Validator for field "' . $field . '" already defined');
     }
     if (null !== $message) {
         $validator->setMessage($message);
     }
     $this->validators[$field] = $validator;
     return $this;
 }
Пример #2
0
 /**
  * @return \Nano\Validator\Composite
  * @param \Nano\Validator $validator
  * @param string|null $message
  */
 public function append(\Nano\Validator $validator, $message = null)
 {
     $validator->setMessage($message);
     $this->validators[] = $validator;
     return $this;
 }