public function addError($messageCode, $field = '*', $options = []) {
        $error = [];
        if (substr($messageCode, 0, 1) === '@') {
            $error['message'] = substr($messageCode, 1);
        } else {
            $error['code'] = $messageCode;
        }
        if (is_array($field)) {
            $fieldname = array_select(['path', 'name'], $field);

            if ($fieldname) {
                // This is a full field object.
                $fieldKey = $fieldname;
                $error['field'] = $fieldKey;
            } else {
                $fieldKey = '*';
                $error['field'] = $field;
            }
        } else {
            $fieldKey = $field;
            if ($field !== '*') {
                $error['field'] = $field;
            }
        }

        if (is_array($options)) {
            $error += $options;
        } else if (is_int($options)) {
            $error['status'] = $options;
        }

        $this->errors[$fieldKey][] = $error;

        return $this;
    }
public function addError($messageCode, $field = '*', $options = []) {
        $error = [];
        if (substr($messageCode, 0, 1) === '@') {
            $error['message'] = substr($messageCode, 1);
        } else {
            $error['code'] = $messageCode;
        }
        if (is_array($field)) {
            $fieldname = array_select(['path', 'name'], $field);

            if ($fieldname) {
                // This is a full field object.
                $fieldKey = $fieldname;
                $error['field'] = $fieldKey;
            } else {
                $fieldKey = '*';
                $error['field'] = $field;
            }
        } else {
            $fieldKey = $field;
            if ($field !== '*') {
                $error['field'] = $field;
            }
        }

        if (is_array($options)) {
            $error += $options;
        } else if (is_int($options)) {
            $error['status'] = $options;
        }

        $this->errors[$fieldKey][] = $error;

        return $this;
    }
public function addError ( $ messageCode , $ field = '*' , $ options = [ ] ) { $ error = [ ] ; if ( substr ( $ messageCode , 0 , 1 ) === '@' ) { $ error [ 'message' ] = substr ( $ messageCode , 1 ) ; } else { $ error [ 'code' ] = $ messageCode ; } if ( is_array ( $ field ) ) { $ fieldname = array_select ( [ 'path' , 'name' ] , $ field ) ; if ( $ fieldname ) { // This is a full field object. $ fieldKey = $ fieldname ; $ error [ 'field' ] = $ fieldKey ; } else { $ fieldKey = '*' ; $ error [ 'field' ] = $ field ; } } else { $ fieldKey = $ field ; if ( $ field !== '*' ) { $ error [ 'field' ] = $ field ; } } if ( is_array ( $ options ) ) { $ error += $ options ; } else if ( is_int ( $ options ) ) { $ error [ 'status' ] = $ options ; } $ this -> errors [ $ fieldKey ] [ ] = $ error ; return $ this ; }
Add an error.

@param string $messageCode The message translation code.
If you add a message that starts with "@" then no translation will take place.
@param string|array $field The name of the field to add or an array of fields if the error applies to
more than one field.
@param int|array $options An array of additional information to add to the error entry or a numeric error code.
@return Validation Returns $this for fluent calls.
Add an error .