yii\validators\Validator::validate PHP Метод

validate() публичный Метод

You may use this method to validate a value out of the context of a data model.
public validate ( mixed $value, string &$error = null ) : boolean
$value mixed the data value to be validated.
$error string the error message to be returned, if the validation fails.
Результат boolean whether the data is valid.
    public function validate($value, &$error = null)
    {
        $result = $this->validateValue($value);
        if (empty($result)) {
            return true;
        }
        list($message, $params) = $result;
        $params['attribute'] = Yii::t('yii', 'the input value');
        if (is_array($value)) {
            $params['value'] = 'array()';
        } elseif (is_object($value)) {
            $params['value'] = 'object';
        } else {
            $params['value'] = $value;
        }
        $error = Yii::$app->getI18n()->format($message, $params, Yii::$app->language);
        return false;
    }