Class: ConstraintViolationMessages

ConstraintViolationMessages()

<brut-cv-messages>

Custom element to translate keys from external:ValidityState into actual messges for a human. This works by inserting <brut-cv> elements as children, where the key represents the particular errors present in the ValidityState passed to createMessages. Note that this will not insert an element for customError, since there can't be any sort of general error message to correspond to that.

Constructor

new ConstraintViolationMessages()

Properties:
Name Type Description
input-name string

if set, this indicates this element contains constraint violation messages for the input with this name inside the form this element is in. Currently doesn't affect this element's behavior, however AjaxSubmit will use it to locate where it should insert server-side errors.

Source:
See:

Methods

clearClientSideMessages()

Clear any client-side messages previously inserted by another element. This is useful to remove potentially out-of-date messages to replace with up-to-date ones.

Source:

clearServerSideMessages()

Clear any server-side messages previously inserted by another element or rendered from the server. This is useful to remove potentially out-of-date messages to replace with up-to-date ones.

Source:

createMessages(validityState, inputName)

Creates error messages based on the passed ValidityState and input name.

This should be called as part of a Form validation event to provide a customized UX for the error messages, beyond what the browser would do by default. The keys used are the same as the attributes of a ValidityState, so for example, a range underflow would mean that validity.rangeUnderflow would return true. Thus, a <brut-cv> would be created with key="cv.fe.rangeUnderflow".

The cv.fe is hard-coded to be consistent with Brut's server-side translation management.

Parameters:
Name Type Description
validityState ValidityState

the return from an element's validity when it's found to have constraint violations.

inputName String

the element's name.

Source: