Exemple #1
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;
	}
Exemple #2
0
 /**
  * Filled validator: has been any radio button selected?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     return $control->getValue() !== NULL;
 }
Exemple #3
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();
 }
Exemple #4
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;
 }
Exemple #5
0
 /**
  * Filled validator: is control filled?
  * @param  IFormControl
  * @return bool
  */
 public static function validateFilled(IFormControl $control)
 {
     return (string) $control->getValue() !== '';
     // NULL, FALSE, '' ==> FALSE
 }
Exemple #6
0
 public static function validateFilled(IFormControl $control)
 {
     return $control->getValue() instanceof DateTime;
 }