keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

textfield: don't validate with `pattern.regex` when `isRequired: false`

Open stefanprobst opened this issue 6 months ago • 0 comments

when a text field has the following validation:

fields.text({
  label: "Twitter",
  validation: { isRequired: false, pattern: { regex: /^@.+/, message: "Must start with '@'." } },
})

i had expected that the regex pattern would only be checked when the optional field had a text value, but not when it is left empty.

stefanprobst avatar Aug 09 '24 15:08 stefanprobst