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