*/ private array $errors = array(); /** * Build the exception from the full list of field-level messages. * * @since 1.0.0 * * @param array $errors The field-level validation messages. * @return self The exception carrying every message. */ public static function withErrors( array $errors ): self { $exception = new self( (string) ( $errors[0] ?? '' ) ); $exception->errors = array_values( $errors ); return $exception; } /** * The individual field-level validation messages. * * @since 1.0.0 * * @return array The messages, in input order. */ public function getErrors(): array { return array() !== $this->errors ? $this->errors : array( $this->getMessage() ); } }