Sun. Jan 22nd, 2023

Validation check techniques

Validation is the process of ensuring that input conforms to predefined rules. Validation should occur as soon as possible after data has been input – before it has been processed.

Examples of types of validation include:

Presence check

A presence check can be used on fields where a value is required; a presence check will test whether or not the field has been filled in.

Range check

A range check is used to ensure that a value sits between an upper and lower limit; this can be used for areas such as:

  • Quantity of items being ordered – can’t be less than 0, and maybe there’s a maximum order limit
  • Filter out improbable values – for example you are asking someone’s age, and don’t expect many people of 140 years old to respond…
  • To make sure that a date lies in between a set range – for example on a booking site, you shouldn’t be able to pick a date in the past

Data-type check

By default, all data entry methods that allow a user to key in data will accept any character. Therefore it is vital when expecting, for example a numeric input, that the data type is verified before any further operations are processed. Attempting to convert a non-numeric value into a numeric value will cause an application crash.

Constraint check

A constraint check will check the consistency of entered data, for example against a regular expression. A regular expression can be used to describe a valid input format – maybe a pattern that represents an email address, or a car registration plate.