Documentation / @zerotal/flow / index / ValidationError
Class: ValidationError
Defined in: flow/src/validation.ts:50
Error thrown by Component.validate() when one or more fields fail validation.
Remarks
Extends ZerotalError with code "E_VALIDATION" and HTTP status 422. The failing fields are
carried on errors, a map of field name → array of human-readable messages. The Flow
WebSocket handler catches this and re-renders the component with the populated error bag rather
than surfacing it as a crash.
Example
try {
this.validate();
} catch (err) {
if (err instanceof ValidationError) {
// err.errors === { email: ["The email field is required."] }
}
}
Extends
Constructors
Constructor
new ValidationError(
errors):ValidationError
Defined in: flow/src/validation.ts:52
Parameters
errors
Record<string, string[]>
Map of field name to its array of validation error messages.
Returns
ValidationError
Overrides
Properties
code
readonlycode:string
Defined in: core/src/errors/ZerotalError.ts:18
Inherited from
status
readonlystatus:number=500
Defined in: core/src/errors/ZerotalError.ts:19
Inherited from
context?
readonlyoptionalcontext?:Record<string,unknown>
Defined in: core/src/errors/ZerotalError.ts:20
Inherited from
errors
readonlyerrors:Record<string,string[]>
Defined in: flow/src/validation.ts:52
Map of field name to its array of validation error messages.