Field validators allow you to enforce stricter rules about the data a user can import.
validators
parameter—an array of objects, each with a validate
rule. Optionally, include an errorMessage
to show users a custom tooltip when validation fails.
{ validate: "unique_case_insensitive" }
.unique_with
validator can be used to validate uniqueness across multiple fields.unique_with
validator can be used to validate uniqueness across multiple fields.To use it, place a unique_with
validator on each field that you want to be part of the uniqueness validation, all sharing the same uniqueKey
.Here is an example set of fields using unique_with
validators used to validate that the combination of the first name and last name fields are unique.regex_match
validator.Conversely, you can validate that a field does not match a regular expression with the regex_exclude
validator.regex
key as either a RegExp
literal/object or a string.If you choose to use a string, be careful to properly escape special characters in your regex. For example, the regex /^"\d+"$/
should be passed in as "^\"\\d+\"$"
. Additionally, if using a string, note that you cannot pass in regex flags directly in your regex. Instead, you may optionally provide a regexOptions
parameter with the validator which takes an object with the following keys:ignoreCase: boolean
- Case insensitive flag (regex flag i
)dotAll: boolean
- Matches all including any line breaks (regex flag s
)multiline: boolean
- Multiline flag (regex flag m
)unicode: boolean
- Unicode flag (regex flag u
)
{ validate: "require_with", fields: [<fieldKey>, ...] }
This will require that the field has a value if any of the fields listed in the fields
array are non-empty.
{ validate: "require_without", fields: [<fieldKey>, ...] }
This will require that the field has a value if any of the fields listed in the fields
array are empty.
{ validate: "require_with_all", fields: [<fieldKey>, ...] }
This will require that the field has a value if all of the fields listed in the fields
array are non-empty.
{ validate: "require_without_all", fields: [<fieldKey>, ...] }
This will require that the field has a value if all of the fields listed in the fields
array are empty.
{ validate: "require_with_values", fieldValues: { <fieldKey>: <fieldValue>, ... } }
This will require that the field has a value if any of the fields contain the corresponding value specified under fieldValues
.
{ validate: "require_without_values", fieldValues: { <fieldKey>: <fieldValue>, ... } }
This will require that the field has a value if any of the fields do not contain the corresponding value specified under fieldValues
.
{ validate: "require_with_all_values", fieldValues: { <fieldKey>: <fieldValue>, ... } }
This will require that the field has a value if all of the fields contain the corresponding value specified under fieldValues
.
{ validate: "require_without_all_values", fieldValues: { <fieldKey>: <fieldValue>, ... } }
This will require that the field has a value if all of the fields do not contain the corresponding value specified under fieldValues
.