Esempio n. 1
0
 /**
  * Filled validator: is control filled?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     return (string) $control->getValue() !== '';
     // NULL, FALSE, '' ==> FALSE
 }
Esempio n. 2
0
 /**
  * Filled validator: has been any radio button selected?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     return $control->getValue() !== NULL;
 }
Esempio n. 3
0
 /**
  * Equal validator: are control's value and second parameter equal?
  * @param  IFormControl
  * @param  mixed
  * @return bool
  */
 public static function validateEqual(IFormControl $control, $arg)
 {
     $value = $control->getValue();
     foreach (is_array($value) ? $value : array($value) as $val) {
         foreach (is_array($arg) ? $arg : array($arg) as $item) {
             if ((string) $val === (string) ($item instanceof IFormControl ? $item->value : $item)) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
Esempio n. 4
0
 /**
  * Filled validator: has been any file uploaded?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     $file = $control->getValue();
     return $file instanceof HttpUploadedFile && $file->isOK();
 }
Esempio n. 5
0
 /**
  * Filled validator: has been any item selected?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     $value = $control->getValue();
     return is_array($value) ? count($value) > 0 : $value !== NULL;
 }