Describe the bug
The documentation seems to disagree with itself - the description doesn't match the example provided (which seems correct based on testing).
To Reproduce
Read this section of the docs:
string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema
An alternate signature for string.matches with an options object. excludeEmptyString, when true, short circuits the regex test when the value is an empty string, making it a easier to avoid matching nothing without complicating the regex.
let schema = string().matches(/(hi|bye)/, { excludeEmptyString: true });
await schema.isValid(''); // => true
In particular, the "easier to avoid matching nothing without complicating the regex" part seems to suggest empty strings would not validate. (Opposite of observed behavior.)
Expected behavior
Setting excludeEmptyString to true allows/validates empty strings even if they don't match the regex so the documentation should clearly state that.
Perhaps something like "... excludeEmptyString, when true, short circuits the regex so empty strings pass validation without complicating the regex."
Platform (please complete the following information):
- Browser: Chrome 116
- Yup Version: 1.0.2
Describe the bug
The documentation seems to disagree with itself - the description doesn't match the example provided (which seems correct based on testing).
To Reproduce
Read this section of the docs:
string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema
An alternate signature for string.matches with an options object.
excludeEmptyString, when true, short circuits the regex test when the value is an empty string, making it a easier to avoid matching nothing without complicating the regex.In particular, the "easier to avoid matching nothing without complicating the regex" part seems to suggest empty strings would not validate. (Opposite of observed behavior.)
Expected behavior
Setting
excludeEmptyStringto true allows/validates empty strings even if they don't match the regex so the documentation should clearly state that.Perhaps something like "... excludeEmptyString, when true, short circuits the regex so empty strings pass validation without complicating the regex."
Platform (please complete the following information):