Esempio n. 1
0
 /**
  * Callback used on add this attribute to a datetime input
  *
  * @param Input $input The input in which the attribute will be added
  * @param mixed $value The value of this attribute
  *
  * @return mixed The value sanitized
  */
 protected static function checkDatetimeAttribute(Input $input, $value)
 {
     if (!date_create($value)) {
         throw new \InvalidArgumentException('The min value must be a valid datetime');
     }
     $input->addValidator('min', array(__CLASS__, 'validateDatetime'));
     return $value;
 }
Esempio n. 2
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param Input $input The input in which the attribute will be added
  * @param mixed $value The value of this attribute
  *
  * @return integer $value The value sanitized
  */
 public static function onAdd(Input $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;
 }
Esempio n. 3
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param Input $input The input in which the attribute will be added
  * @param mixed $value The value of this attribute
  *
  * @return boolean $value The value sanitized
  */
 public static function onAdd(Input $input, $value)
 {
     if (!is_bool($value)) {
         throw new \InvalidArgumentException('The required value must be a boolean');
     }
     $input->addValidator('required', array(__CLASS__, 'validate'));
     return $value;
 }
Esempio n. 4
0
 /**
  * Callback used on add this attribute to an input
  *
  * @param Input $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 $input, $value)
 {
     $input->addValidator('accept', array(__CLASS__, 'validate'));
     return $value;
 }