Skip to content

Instantly share code, notes, and snippets.

@longtc
Created July 29, 2020 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longtc/24eee072ed3b57df48001ed44df33f2b to your computer and use it in GitHub Desktop.
Save longtc/24eee072ed3b57df48001ed44df33f2b to your computer and use it in GitHub Desktop.
const contentType = {
urlEncoded: 'application/x-www-form-urlencoded',
json: "application/json; charset=utf-8"
};
const headers = {
"Accept": "application/json, text/*"
};
// Validator
// http://emailregex.com/
export function validateEmail(email) {
// eslint-disable-next-line no-useless-escape
return /^(([^<>()\[\]\\.,;:\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,}))$/.test(
String(email).toLowerCase(),
);
}
export function validatePhone(phone) {
return String(phone).match(/^[0-9\b-.]+$/);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment