addRule() public method

public addRule ( $validator, $message = NULL, $arg = NULL )
Ejemplo n.º 1
0
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     $this->operation = $operation;
     if ($operation === Form::FLOAT) {
         $this->addFilter(callback(__CLASS__, 'filterFloat'));
     }
     return parent::addRule($operation, $message, $arg);
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     if ($operation === Form::FILLED) {
         $operation = __CLASS__ . '::validateDateTimeInputFilled';
     } elseif ($operation === Form::VALID) {
         $operation = __CLASS__ . '::validateDateTimeInputValid';
     }
     return parent::addRule($operation, $message, $arg);
 }
Ejemplo n.º 3
0
 /**
  * Adds a validation rule.
  * @param  mixed      rule type
  * @param  string     message to display for invalid data
  * @param  mixed      optional rule arguments
  * @return FormControl  provides a fluent interface
  */
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     switch ($operation) {
         case Form::EQUAL:
             if (!is_array($arg)) {
                 throw new \Nette\InvalidArgumentException(__METHOD__ . '(' . $operation . ') must be compared to array.');
             }
     }
     return parent::addRule($operation, $message, $arg);
 }
 /**
  * Adds a validation rule
  *
  * @param mixed $validator rule type
  * @param string $message message to display for invalid data
  * @param mixed $arg optional rule arguments
  * @return self
  */
 public function addRule($validator, $message = NULL, $arg = NULL)
 {
     $class = get_called_class();
     switch ($validator) {
         case Form::MIN:
             $this->range['min'] = $arg;
             $arg = $arg->format($this->format);
             $validator = $class . '::validateMin';
             break;
         case Form::MAX:
             $this->range['max'] = $arg;
             $arg = $arg->format($this->format);
             $validator = $class . '::validateMax';
             break;
         case Form::RANGE:
             $this->range['min'] = $arg[0];
             $this->range['max'] = $arg[1];
             $arg[0] = $arg[0]->format($this->format);
             $arg[1] = $arg[1]->format($this->format);
             $validator = $class . '::validateRange';
             break;
         default:
             break;
     }
     return parent::addRule($validator, $message, $arg);
 }