Allow options to be passed to string.email().#488
Allow options to be passed to string.email().#488nlindley wants to merge 6 commits intohapijs:masterfrom
Conversation
|
|
|
Would you recommend supporting a subset of the options and mapping those to the ones expected by isemail? |
|
|
|
@nlindley can you make the change about checkDNS ? |
|
@Marsup Sure. I thought you wanted to hold off until async could be supported. I’ll get you something either this afternoon or tomorrow depending on how much time I have available. |
|
@nlindley May I suggest you validate the passed options yourself immediately, to catch errors at configuration time? |
|
I have updated the branch which disallows @kanongil If you would prefer to whitelist options that are known to not cause problems, I can do that instead. |
|
I should also mention, |
|
@nlindley I was not really concerned about how well |
|
@kanongil All right. I’ll get it fixed up in the morning. |
|
I’ve pushed another update. I’ve used Joi to validate the isemail options. Doing this is more complicated, so let me know if you want to go a different route, or if there are style changes needing made. |
|
isemail seems to be doing a far more complex validation of its input, we won't be able to guarantee it doesn't fail, I'm wondering if it's worth it at all. Wouldn't it be a better solution to do a test run on a generated email ? |
|
I’m not sure that would keep somebody from trying to set |
|
@kanongil I think we're gonna rollback that change, this seems like an unnecessary pain for joi. |
|
No problem – it was merely a suggestion towards improving the user experience (at the expense of some additional complexity). Sidenote: Does joi handle the exceptions that can be thrown from |
|
@nlindley sorry for the back and forth, I finally took time to read in details about isemail. I think we'll go with this :
@kanongil is right about errors, isemail seems to throw a few by looking at its code, we should be defensive about that. What worries me is that these cases are not even tested in that lib. Hopefully I got this right this time :) |
|
Sounds good. minDomainAtoms can actually be 0, so I'm checking that it is >= 0. The check you propose for errorLevel is a little more strict than what isemail requires, but I’d be surprised if that causes anybody problems. |
|
Nevermind about the minDomainAtoms. I missed the coercion in the |
|
Stricter in what way ? |
|
I was mistaken. See my "Nevermind" comment. |
|
@Marsup Actually, errorLevel is a little stricter. I got confused on which property you were asking about. In isemail, if |
|
I don't see why that module does that, let's keep it strict. |
|
The assertions get a little lengthy. Let me know if the latest commit is more of what you were thinking. |
|
@nlindley I took over and fixed a last few details, thanks a lot for your work. |
|
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. |
Fixes #400.