Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Validation rules are run when data is provided to the system, to check that the data conforms. This guide focuses on validating data which is inputted manually by users via fields.

Validation can be invoked by one a number of two actions, either when . When the user:

  1. Dirties a an individual field, i.e. on the fly, as they as entering content into a field. This is the primary validation method.

  2. Selects “Save”Performs a “Save” action covering multiple fields. Fields which cannot be validated when they are dirtied should instead be validated on an action such as “Save” or “Confirm”. Actions which trigger a save can be made on the client-side or the back-end.

    1. Client-side: When fields are validated in bulk on the client-side, any invalid fields should apply the main guidelines defined below.

    2. Server side: A long term goal is for fields validated on

    the “Save” action
    1. the server side to also follow the main guidelines. As this is not feasible at the moment a separate set of guidelines exists for server side validation.

When a field contains invalid data it is in an “error state”. When in this state:

  • The data should not be saved

  • An error message should be displayed beneath the field

  • The user should be able to move freely around the form or page and not be locked to the field

  • Any save options should be inactive, unless validation for the field can only be run on “save”

  • If the user leaves the form or page they should see the standard “Unsaved changes” warning [link to be added]

Note that a field can be in a warning state, rather than an error state. Fields in a warning state can still be saved and are not considered to be invalid.

...

Messages should be informative yet short. We should avoid using words such as “please”. [add more stop words?]

Empty mandatory field

When a mandatory field is empty the error message should state: “Enter a/an/the {field label}”.

...

  • The field background color should change to the standard error background color

  • Field label text and feedback text be displayed in the standard error foreground color [to be reviewed]

A field may instead be in a warning state. In this case the warning styles would be applied.

Dependent fields

Validation on save

When validation is run on a user triggered “save” action and errors are found, some guidelines, additional to those described above, must be applied:

  1. All invalid fields should be displayed in the error state

  2. Focus should move to the first invalid field

  3. An “error” toast should be displayed, letting the user know their submission contains errors and has not been saved. The toast should display:

    • A heading “Error”

    • The text “The {name/entity} was not saved. Some of the data is One or more fields are invalid. Please correct any errors and retry” [using a general message here as the specifics are displayed in context]

...

...

Server side validation

When fields are validated on the server side, it is not possible to put an individual field into an “error” state in the UI. Instead any errors must be indicated in a toast message. The longer term goal is to bring server side validation inline with the above guidelines.

The toast should display:

  • A heading “Error”

  • The text “The {name/entity} was not saved. One or more fields are invalid. Please fix the following issue(s) and retry”

  • A list of errors in the form: {field label} must {description}

...

The toast should display either until the user closes it, or when they re-trigger the validation.