Validation rules
There are two ways to apply a validation rule to a field:
1. By passing down the name of the validation rule as the
type
property:2. By importing the preferred validation rule and passing it down as the
type
property. This should be the default approach when using dynamic validation rules or when using some of the formfusion's validation sets.Currently, FormFusion includes 62 generic validation rules. To use some of the more specific validation rules, you'll need to install the corresponding package.
List of available sets of validation rules:
@formfusion/postcodes
@formfusion/licence-plates
@formfusion/iban
@formfusion/passports
@formfusion/phones
@formfusion/tin
@formfusion/vat
Type | Description |
---|---|
| Validation rule for minimum character length (5 or more) |
| Validation rule for maximum character length (7 or fewer) |
| Validation rule for character length within a range (4 to 8 characters) |
| Validation rule for minimum number of letters (3 or more) |
| Validation rule for maximum number of letters (5 or fewer) |
| Validation rule for a range of letters (2 to 5 letters) |
| Validation rule used to check if the input value is contained in a given string. |
| Validation rule used when you need to validate if the input value matches a specific string. |
| Validation rule used to check if a the input value matches any of the specified items in an array. |
| Validation rule used to check if a the input value does not match any of the specified items in an array. |
| Used for restricting a field to contain only numbers |
| Used for restricting a field to contain only letters |
| Used for restricting a field to contain only letters or numbers |
| Used for validating lowercase strings. A lowercase string is considered valid if it contains only lowercase letters. |
| Used for validating uppercase strings. An uppercase string is considered valid if it contains only uppercase letters. |
| Used for validating boolean values. A boolean value is considered valid if it matches 'true,' 'false,' 'yes,' 'no,' '1,' or '0.' |
| Used for validating hexadecimal color codes. A valid hexadecimal color code starts with '#' and is followed by six valid hexadecimal characters. |
| Used for fields for editing an email address |
| Used for fields for editing a url |
| Used for username fields. A valid username is considered to contain only alphanumeric characters, @, _, or - |
| Used for search bar fields. It allows only numbers, letters and spaces |
| Used for fields for editing a telephone number.A valid phone number should start with a '+' following the country prefix of max 4 digits, a space and the phone number of max 10 characters |
| Used for secured password fields. A secured password contains of at least 8 characters of which one lower one uppercase letter, a number and a special character |
| Used for credit card number fields. This is the most basic example of CCN that validates only the number of numeric characters. It allows values with only 16 characters |
| Used for credit card number fields. A credit card number is considered valid if it contains only 16 numeric characters delimited by hyphens |