Example #1
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param InputInterface $input The input in which the attribute will be added
  * @param mixed          $value The value of this attribute
  *
  * @return mixed $value The value sanitized
  */
 public static function onAdd($input, $value)
 {
     if (!is_float($value) && !is_int($value)) {
         throw new \InvalidArgumentException('The min value must be a float number');
     }
     $input->addValidator('min', array(__CLASS__, 'validate'));
     return $value;
 }
Example #2
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param InputInterface $input The input in which the attribute will be added
  * @param mixed          $value The value of this attribute
  *
  * @return mixed $value The value sanitized
  */
 public static function onAdd($input, $value)
 {
     if (!is_int($value) || $value < 0) {
         throw new \InvalidArgumentException('The maxlength value must be a non-negative integer');
     }
     $input->addValidator('maxlength', array(__CLASS__, 'validate'));
     return $value;
 }
Example #3
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param InputInterface $input The input in which the attribute will be added
  * @param mixed          $value The value of this attribute
  *
  * @return mixed $value The value sanitized
  */
 public static function onAdd($input, $value)
 {
     if (!is_bool($value)) {
         throw new \InvalidArgumentException('The required value must be a boolean');
     }
     $input->addValidator('required', array(__CLASS__, 'validate'));
     return $value;
 }
Example #4
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param InputInterface $input The input in which the attribute will be added
  * @param mixed          $value The value of this attribute
  *
  * @return mixed $value The value sanitized
  */
 public static function onAdd($input, $value)
 {
     $input->addValidator('pattern', array(__CLASS__, 'validate'));
     return $value;
 }