Habari\FormValidators::validate_required PHP Метод

validate_required() публичный статический Метод

A validation function that returns an error if the value passed in is not set.
public static validate_required ( $value, FormControl $control, FormContainer $form, string $warning = null ) : array
$control FormControl The control that defines the value
$form FormContainer The container that holds the control
$warning string An optional error message
Результат array An empty array if the value exists, or an array with strings describing the errors
    public static function validate_required($value, $control, $form, $warning = null)
    {
        if (empty($value) || $value == '') {
            $warning = empty($warning) ? _t('A value for the %s field is required.', array($control->get_label())) : $warning;
            return array($warning);
        }
        return array();
    }