string.matches throws error when we pass a string as second parameter
See original GitHub issueDescribe the bug In 0.28.1, these 2 signatures work:
string.matches(regex: Regex, message?: string | function): Schema
string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema
In 0.28.2:
The first one throws an error.
Cannot use 'in' operator to search for 'excludeEmptyString' in <message>
The bug has been introduced here: https://github.com/jquense/yup/commit/27e5d684acb7563fa44c4da6baa8e81c94a08c34#diff-57c5960218f1091895b3610a7d779378R79
If options
is a string, we cannot make this operation 'excludeEmptyString' in options
.
To Reproduce
const schema = yup.string().matches(/test/, 'My message')
await schema.isValid('hi')
Expected behavior Should not throw an error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:5
Top Results From Across the Web
Java - Trying to throw an error based on 2 string values in the ...
The first part of the code seems to work but the second part is saying its always true and I get an error...
Read more >Regular Expressions :: Eloquent JavaScript
If you pass it a string, it will return a Boolean telling you whether the string contains a match of the pattern in...
Read more >4. Pattern Matching with Regular Expressions - Java ... - O'Reilly
In the second frame, I have finished typing the regex, and typed the data string as QA577 (which you should expect to match...
Read more >String (Java Platform SE 8 ) - Oracle Help Center
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. String(char[] value, int offset, ......
Read more >String.prototype.charAt() - JavaScript - MDN Web Docs
The String object's charAt() method returns a new string consisting of the ... (str.length <= i + 1) { throw new Error("High surrogate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also had this error. The function expects an object, but a string is passed to it and therefore an error message is given. A rollback fixed the issue also for me, but I also made this pull request #801 for a suggested fix.
Same problem for me, rollback in 0.28.1 solve the problem