Skip to main content
cngx-src documentation

CNGX_ERROR_MESSAGES

Tokenv0.1.0WCAG AA

InjectionToken<ErrorMessageMap>

Description#

Maps each validation error kind to the function that renders its message. CngxFieldErrors and CngxFormErrors resolve their text against it.

An unmapped kind falls back, in order:

  • the error's own message
  • the raw kind string

Populated by withErrorMessages(...) through provideFormField, or by the provideErrorMessages(...) shortcut. The default factory returns an empty map, so without a provider every error renders by its fallback string.

providers: [provideFormField(withErrorMessages({
  required: () => 'Required.',
  minLength: (e) => `Min ${(e as { minLength: number }).minLength} chars.`,
}))]

Type#

InjectionToken<ErrorMessageMap>