An empty string is considered as a valid email
See original GitHub issueDescribe the bug
yup.string().email().validateSync('')
throws no errors and returns an empty string.
And
var yup = require("yup")
const schema = yup.object().shape({
email: yup.string().email(),
});
schema.validateSync({email: ''})
Also works without errors.
To Reproduce
Just run the code
var yup = require("yup")
yup.string().email().validateSync('')
const schema = yup.object().shape({
email: yup.string().email(),
});
schema.validateSync({email: ''})
here https://npm.runkit.com/yup
Expected behavior
An error that the email is invalid must be thrown.
Platform (please complete the following information):
Node.js 10.15.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Javascript regex for email and empty string - Stack Overflow
I'm using this regex /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/ for validating email format but when I leave the the email field blank it shows an error ...
Read more >Error while sending email through Webmail | Blue Prism Product
It means you have been trying to add an empty string as an email address, which is not valid. You may want to...
Read more >How to verify that strings are in valid email format
The IsValidEmail method merely determines whether the email format is valid for an email address; it doesn't validate that the email exists.
Read more >Validation of property with EmailAddressAttribute fails on empty
When a string property is decorated with an EmailAddressAttribute validation fails when removing the address. This occurs on a fresh Alloy ...
Read more ><input type="email"> - HTML: HyperText Markup Language
Notice that it's considered valid when empty and when a single validly-formatted email address is entered, but is otherwise not considered valid ...
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
an empty string is considered a missing value for strings, so most validations besides
required
ignore it. If you want to check empty strings as invalid, mark the field asrequired
as noted above thanks!@akmjenkins You should read my previous message again and run the code:
Email isn’t a required field for me.