Skip to content

Instantly share code, notes, and snippets.

@MicroBenz
Last active August 15, 2018 11:01
Show Gist options
  • Save MicroBenz/0ec109f0abeab88a53d6fb94f86adf9e to your computer and use it in GitHub Desktop.
Save MicroBenz/0ec109f0abeab88a53d6fb94f86adf9e to your computer and use it in GitHub Desktop.
v8n
export function isEmpty(test) {
return test === null || test === undefined || test === '';
}
export function isNumber(test) {
return test !== null && test !== undefined && typeof test === 'number';
}
export function isGreaterThanZero(test) {
return !isEmpty(test) && isNumber(test) && test > 0;
}
export function isEmail(test) {
const emailRegex = /^(([^<>()\[\]\\.,;:\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,}))$/;
return emailRegex.test(test);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment