joi-browser icon indicating copy to clipboard operation
joi-browser copied to clipboard

Email validation returning errors for valid emails in IE11

Open keirlawson opened this issue 6 years ago • 9 comments

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 avatar Jun 14 '18 10:06 keirlawson

@keirlawson see if the latest versions also do the same thing

jeffbski avatar Jun 14 '18 23:06 jeffbski

On the latest version (13.4.0) I now get Object doesn't support property or method 'normalize'

keirlawson avatar Jun 15 '18 08:06 keirlawson

You need to have a shim for String.normalize, should be fairly easy to add to your build.

Marsup avatar Jun 15 '18 08:06 Marsup

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.

jeffbski avatar Jun 15 '18 22:06 jeffbski

I have the same problem. My email doesn't become a valid email. I tried to install unorm but it still doesn't work.

emmaberglund avatar Sep 04 '18 11:09 emmaberglund

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.

cjnqt avatar Sep 04 '18 14:09 cjnqt

Is this still an issue? Was it ever fixed?

nlucero avatar Jan 29 '20 21:01 nlucero

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.

jeffbski avatar Feb 07 '20 20:02 jeffbski

Joi-browser email validation allows user_email@gmail instead of [email protected], Any solution ???

BasitMaqsood avatar Apr 29 '20 06:04 BasitMaqsood