Skip to main content
cngx-src documentation

withErrorMessages

Functionforms/field

projects/forms/field/form-field.token.ts

Description#

Register the application-wide validation error message map. Each entry maps an error kind to a function that renders its display string; CngxFieldErrors and CngxFormErrors resolve messages against it.

Merges into any messages already on the config, so later features add to or override earlier ones by kind.

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

Signature#

withErrorMessages(messages: ErrorMessageMap)

Parameters#

@parammessagesErrorMessageMap

Returns#

FormFieldFeature