jesse2
August 16, 2019, 2:04am
1
During signup, the lock form does some email validation:
Other parts of our system also validate emails and we want to provide a consistent experience across our whole app regarding email rules.
What are the exact rules Auth0 uses for this field? Or the regex used?
Hey there @jesse2 !
Not sure about that but let me do the research and get back to you soon!
jesse2
August 28, 2019, 4:31am
3
Thanks @konrad.sopala
Did you find anything yet?
1 Like
Hey there @jesse2 !
I was told by our engineering team that we do have no doc on the rules we use in Lock for validating those fields. The only source of knowledge for that is to inspect Lock source code.
jesse2
October 3, 2019, 11:06pm
6
Thanks for the suggestion. I believe I’ve found it here:
import trim from 'trim';
import { setField } from './index';
import { endsWith } from '../utils/string_utils';
import { isHRDEmailValid } from '../connection/enterprise';
import * as i18n from '../i18n';
const regExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
export function validateEmail(str) {
return isEmail(str);
}
export function isEmail(str) {
const result = regExp.exec(trim(str.toLowerCase()));
return !!result && result[0] !== null;
}
const regExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1 Like
Thanks a lot for sharing that with the rest of community!
This topic now contains incorrect information: Email validation rules, please make them public knowledge
Auth0 used to use the regex shown, but they have since switched to using isEmail from the npmjs validator package.
Unfortunately the topic was closed so I can no longer reply and correct the misinformation. Please update the topic with correct info.
3 Likes
Thank you @jr.willett ! I have moved your post to this topic so that others will know that isEmail
from the validator package is what Auth0 uses now.
2 Likes