joi-browser
joi-browser copied to clipboard
Email validation returning errors for valid emails in IE11
var schema = joi.object({
sender: joi.string().email().required()
})
joi.validate({sender: '[email protected]'}, schema)
This produces the following error: "child "sender" fails because ["sender" must be a valid email]"
regardless of the email address in question on IE11 on Windows 10
@keirlawson see if the latest versions also do the same thing
On the latest version (13.4.0) I now get Object doesn't support property or method 'normalize'
You need to have a shim for String.normalize, should be fairly easy to add to your build.
Thanks @Marsup!
@keirlawson in your project try installing the polyfill for String.prototype.normalize.
npm install unorm
Then just require it.
require('unorm'); // this will add normalize to the String prototype.
From compatibility tables, it looks like it is only necessary for IE and possibly Android.
See if that gets you working.
If so, we can add that to the documentation. I think we can just let users that need it add it in once at the app build level. If we build it into joi-browser then it doubles the gzip size from 44KB to 80KB.
I have the same problem. My email doesn't become a valid email. I tried to install unorm but it still doesn't work.
var schema = joi.object({
sender: joi.string().email().required()
})
joi.validate({ sender: '[email protected]'}, schema)
This fails with the error "child "sender" fails because ["sender" must be a valid email]"
in Internet Explorer 11 and latest version of both Joi-browser and Joi.
Adding String.normalize (require('unorm')
) doesn't make any difference.
Is this still an issue? Was it ever fixed?
You could raise an issue in the source repo hapi/joi https://github.com/hapijs/joi This repo was just trying to make it easier to use in the browser. Now that they are planning on supporting browsers natively, the need for this repo will eventually go away. Hopefully the developers might know why this is failing.
Joi-browser email validation allows user_email@gmail instead of [email protected], Any solution ???