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.
...
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.
...
Error messages should always include the name of the field, to support accessibility guidelines.
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}”.
...
“{field label} must begin “http” or “https”
Invalid content
When a field’s content does not conform to any data restriction rules in place, the error message should follow the same format. format:
“{field label} must {description}”
For example, “Latitude must be a number between -90 and 90”
...
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
Rules controlling the validity of data can cover multiple fields, creating dependencies between their content.
When a dependent field’s content does not conform to the rules in place, the error message should follow the format:
“{field label} must {description}”
For example, “End date must be equal to or after the start date”
When a dependency is in place, the value of one field can affect the state of one or more other fields and the behaviour varies depending on the type of rule which is in place.
Rules changing field visibility or availability
Fields can become active or inactive, or completely hidden from view, based on the value of another field. For example:
When the value of field x = “yes” then field y becomes active and mandatory.
For this type of rule the user will not normally see any validation issues. When a field containing a value is made inactive the value should remain visible in the inactive field. [review this] There is no need to display a warning.
Rules changing the allowable values
The set of allowable values for one field can change depending on the value of another. For example, for an Item Type mapping when the “From context” is set to ”DCB”, restrict the set of values available in the “To context” to CIRC, NONCIRC and CIRCAV.
...
In the above example, if the user was to change "From context" from “DCB” to “Lindenwood”, then “CIRC” is no longer a valid value for "To context" and so:
"CIRC" becomes an invalid value for "To context" and is substituted for a valid value: "DCB"
"To context" is put into a warning state to indicate that its value has changed
...
Rules fixing the allowable values
Some dependencies have fixed rules affecting the acceptable values for a field. For example, when entering a date range the end date cannot be before the start date. In this case, neither field is correct so they are both in an error state.
...
Validation on save
Fields should be validated on the fly wherever possible.
When validation is instead run on a user triggered “save” action and errors are found, some guidelines, additional to those described above, must be applied:
...