keystatic
keystatic copied to clipboard
textfield: don't validate with `pattern.regex` when `isRequired: false`
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.