Class: ConstraintViolationMessage

ConstraintViolationMessage()

<brut-cv>

Like Message but specific to constraint violations of input fields. This accepts the name of an input field via input-name, which can be used to locate the field's localized name.

Here is how the field's name is determined:

  1. It will look for a <brut-i18n-translation> element with the key cv.cs.fieldNames.«input-name».
  2. If that's not found, it will attempt to use "this field" by locating a <brut-i18n-translation> element with the key cv.this_field (the underscore being what is used on Brut's server side).
  3. If that is not found, it will use the literaly string "this field" and emit a console warning.

Constructor

new ConstraintViolationMessage()

Properties:
Name Type Description
key string

the i18n translation key to use. It must map to the key of a <brut-i18n-translation> on the page or the element will not render any text.

input-name string

the name of the input, used to insert into the message, e.g. "Title is required".

server-generated boolean

if true, this indicates the element's HTML was generated on the server. This means that your CSS can target it for display in all cases. If this is not present, you may want to avoid showing this element if the form has not been submitted yet. Does not affect behavior.

server-side boolean

if true, this indicates the element contains constraint violation messages from the server. Does not affect behavior.

client-side boolean

if true, this indicates the element contains constraint violation messages from the client, however they may have been generated from the server, since the server may re-evaluate the client-side constraints. Does not affect behavior of this tag.

Source:
See:

Methods

(static) i18nKey(…keyPath)

Returns the I18N key used for front-end constraint violations. This is useful if you need to construct a key and want to follow Brut's conventions on how they are managed.

Parameters:
Name Type Attributes Description
keyPath String <repeatable>

parts of the path of the key after the namespace that Brut manages.

Source: