* Flashes error messages for form fields to the inputErrorsBag, the same * bag "flashValidationErrors" fills. The "@inputError" tag and the Inertia * adapter read them like validation errors. Messages are appended to the * ones already flashed for a field. * * @param messages - Error
(messages: Record<string, string | string[]>)
| 454 | * session.flashInputErrors({ email: 'This email is already registered' }) |
| 455 | */ |
| 456 | flashInputErrors(messages: Record<string, string | string[]>) { |
| 457 | /** |
| 458 | * Null prototype, so a field named like an Object.prototype member |
| 459 | * (e.g. "constructor") does not read an inherited value. |
| 460 | */ |
| 461 | const inputErrors: Record<string, string[]> = Object.assign( |
| 462 | Object.create(null), |
| 463 | this.#getFlashStore('write').get('inputErrorsBag', {}) |
| 464 | ) |
| 465 | |
| 466 | for (const [field, fieldMessages] of Object.entries(messages)) { |
| 467 | inputErrors[field] = (inputErrors[field] ?? []).concat(fieldMessages) |
| 468 | } |
| 469 | |
| 470 | this.flash('inputErrorsBag', inputErrors) |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Flashes validation error messages. Make sure the error is an instance of VineJS ValidationException. |
no test coverage detected