Fields.Validate (fields v2.11.0)

Helper functions to validate the data in certain fields

Summary

Functions

Validate an address. Currently just validates that some input has been given.

Validate the format of an email address using a regex. Uses a slightly modified version of the w3c HTML5 spec email regex (https://www.w3.org/TR/html5/forms.html#valid-e-mail-address), with additions to account for not allowing emails to start or end with '.', and a check that there are no consecutive '.'s.

Validate the length of a name is less than 35 characters

Validates the format of a UK phone number.

Validate the format of an postcode using a regex. All existing postcodes in the UK should pass this validation; some non-existent ones may too if they follow the standard UK postcode format.

Validate the format of a url using a regex. See https://stackoverflow.com/questions/42522442/how-to-validate-a-url-via-a-check-constraint-in-postgres/51965621 for details on how the regex for validation was chosen

Functions

Link to this function

address(address)

Validate an address. Currently just validates that some input has been given.

Validate the format of an email address using a regex. Uses a slightly modified version of the w3c HTML5 spec email regex (https://www.w3.org/TR/html5/forms.html#valid-e-mail-address), with additions to account for not allowing emails to start or end with '.', and a check that there are no consecutive '.'s.

Link to this function

ip_address(ip_address)

Validate the length of a name is less than 35 characters

Link to this function

phone_number(phone)

Validates the format of a UK phone number.

Link to this function

postcode(postcode)

Validate the format of an postcode using a regex. All existing postcodes in the UK should pass this validation; some non-existent ones may too if they follow the standard UK postcode format.

Validate the format of a url using a regex. See https://stackoverflow.com/questions/42522442/how-to-validate-a-url-via-a-check-constraint-in-postgres/51965621 for details on how the regex for validation was chosen