Joi: Email validation doesn't allow emails which are compliant with RFC 6530

Created on 20 Jun 2016  路  17Comments  路  Source: sideway/joi

Context

  • _node version_: 5.11.1
  • _joi version_: 8.4.2
  • _environment_ (node, browser): Node
  • _used with_ (hapi, standalone, ...): Hapi
  • _any other relevant information_:

    What are you trying to achieve or the steps to reproduce ?

  1. Attempt to validate a utf-8 email address such as: j脴[email protected]
  2. Get 'invalid' validation result

Note that this email is considered invalid, which is correct, but permitted by https://tools.ietf.org/html/rfc6530

const schema = Joi.string().email()

Which result you had ?

Email address was marked as invalid. This is a problem as I would now have to use a regexp or simple string validation for email addresses which significantly reduces readability.

What did you expect ?

I'd hope for some method of switching between RFC versions - perhaps by passing in the rfc number. I don't really have any other 'good solutions' for this.

Google, for example support sending and recieving from RFC 6530 emails, but not signing up with them - they would use something like:

const signupSchema = Joi.string().email({compliance: 'rfc5322'})
const sendingSchema = Joi.string().email({compliance: 'rfc6530'})

Of course compliance could be changed to international: true/false' or something similar, but I think compliance is more explicit.

feature

Most helpful comment

This is an option in isemail now, as of 3.1.0. See https://github.com/hapijs/isemail/pull/160 (thanks, @papandreou!)

All 17 comments

This should probably be brought up in https://github.com/hapijs/isemail, but leave this one opened so I can trace it.

Hadn't noticed, this has already been raised here: https://github.com/hapijs/isemail/issues/17

Ha, sorry for misdirecting you :)

isemail v3.0.0 has been released, with proper Unicode support. I made a PR here to update Joi to use it. That should resolve this once and for all ;)

Oh funny, I'd never seen this issue. Interesting idea with the compliance parameter.

As far as I understand, both RFCs will be enabled once I release the next joi version, but this request still stands as it could be interesting to be able to pick and choose whether internationalized emails should be allowed. I think this again falls onto isemail to support that, right @skeggse ?

pick and choose whether internationalized emails should be allowed

why is that?

Because user constraints. There are 2 RFCs, I can imagine systems not being ready to accept both.

I can imagine systems not being ready to accept both.

I've definitely run into this in the past. A simple thing for this might be you use DynamoDB to store email addresses which doesn't support the full set of internationalized characters (without escaping them) so you want to ensure that you have only valid characters.

Is this a requirement prior to releasing international email via [email protected]?

I'd tend to say so, as joi would start accepting emails it didn't previously.

This is an option in isemail now, as of 3.1.0. See https://github.com/hapijs/isemail/pull/160 (thanks, @papandreou!)

Guys, you can close this issue? Apparently is solved :shipit:

Has Joi updated to the latest isemail?

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alekbarszczewski picture alekbarszczewski  路  3Comments

JbIPS picture JbIPS  路  4Comments

chrisegner picture chrisegner  路  4Comments

REBELinBLUE picture REBELinBLUE  路  3Comments

longweiquan picture longweiquan  路  3Comments