src/Validation.php
public function addError(string $field, string $error, $options = []) {
        if (empty($error)) {
            throw new \InvalidArgumentException('The error code cannot be empty.', 500);
        } elseif (!in_array(gettype($options), ['integer', 'array'], true)) {
            throw new \InvalidArgumentException('$options must be an integer or array.', 500);
        }
        if (is_int($options)) {
            trigger_error('Passing an integer for $options in Validation::addError() is deprecated.', E_USER_DEPRECATED);
            $options = ['code' => $options];
        } elseif (isset($options['status'])) {
            trigger_error('Validation::addError() expects $options[\'number\'], not $options[\'status\'].', E_USER_DEPRECATED);
            $options['code'] = $options['status'];
            unset($options['status']);
        }

        $row = ['error' => $error] + $options;
        $this->errors[$field][] = $row;

        return $this;
    }
public function addError(string $field, string $error, $options = []) {
        if (empty($error)) {
            throw new \InvalidArgumentException('The error code cannot be empty.', 500);
        } elseif (!in_array(gettype($options), ['integer', 'array'], true)) {
            throw new \InvalidArgumentException('$options must be an integer or array.', 500);
        }
        if (is_int($options)) {
            trigger_error('Passing an integer for $options in Validation::addError() is deprecated.', E_USER_DEPRECATED);
            $options = ['code' => $options];
        } elseif (isset($options['status'])) {
            trigger_error('Validation::addError() expects $options[\'number\'], not $options[\'status\'].', E_USER_DEPRECATED);
            $options['code'] = $options['status'];
            unset($options['status']);
        }

        $row = ['error' => $error] + $options;
        $this->errors[$field][] = $row;

        return $this;
    }
public function addError ( string $ field , string $ error , $ options = [ ] ) { if ( empty ( $ error ) ) { throw new \ InvalidArgumentException ( 'The error code cannot be empty.' , 500 ) ; } elseif ( ! in_array ( gettype ( $ options ) , [ 'integer' , 'array' ] , true ) ) { throw new \ InvalidArgumentException ( '$options must be an integer or array.' , 500 ) ; } if ( is_int ( $ options ) ) { trigger_error ( 'Passing an integer for $options in Validation::addError() is deprecated.' , E_USER_DEPRECATED ) ; $ options = [ 'code' => $ options ] ; } elseif ( isset ( $ options [ 'status' ] ) ) { trigger_error ( 'Validation::addError() expects $options[\'number\'], not $options[\'status\'].' , E_USER_DEPRECATED ) ; $ options [ 'code' ] = $ options [ 'status' ] ; unset ( $ options [ 'status' ] ) ; } $ row = [ 'error' => $ error ] + $ options ; $ this -> errors [ $ field ] [ ] = $ row ; return $ this ; }
Add an error.

@param string $field The name and path of the field to add or an empty string if this is a global error.
@param string $error The message code.
@param array $options An array of additional information to add to the error entry or a numeric error code.

- **messageCode**: A specific message translation code for the final error.
- **number**: An error number for the error.
- Error specific fields can be added to format a custom error message.
@return $this
Add an error .