framework/helpers/BaseJson.php
public static function errorSummary($models, $options = [])
    {
        $showAllErrors = ArrayHelper::remove($options, 'showAllErrors', false);
        $lines = self::collectErrors($models, $showAllErrors);

        return json_encode($lines);
    }
public static function errorSummary($models, $options = [])
    {
        $showAllErrors = ArrayHelper::remove($options, 'showAllErrors', false);
        $lines = self::collectErrors($models, $showAllErrors);

        return json_encode($lines);
    }
Generates a summary of the validation errors.
@param Model|Model[] $models the model(s) whose validation errors are to be displayed.
@param array $options the tag options in terms of name-value pairs. The following options are specially handled:

- showAllErrors: boolean, if set to true every error message for each attribute will be shown otherwise
only the first error message for each attribute will be shown. Defaults to `false`.

@return string the generated error summary
@since 2.0.14