Commit bdb41116 authored by Matija Obreza's avatar Matija Obreza
Browse files

Better email validator

parent aabdda2f
......@@ -7,7 +7,7 @@ export default class Validators {
public static maxLength = (max) => (value) => value && value.length > max ? `Must be ${max} characters or less` : undefined;
public static maxLength20 = Validators.maxLength(20);
public static emailAddress = (value) => !value || value.match(/^[\w\d\-\+\._]+@[\w\d]+(\.[\w\d\-_]+)*$/g) ? undefined : 'Invalid email address';
public static emailAddress = (value) => !value || value.match(/^[\w\d\-\+\._]+@[\w\d\-_]+(\.[\w\d\-_]+)*$/g) ? undefined : 'Invalid email address';
public static phoneNumber = (value) => !value || value.match(/^\+[\d\-\. ]+( ext\. \d+)?$/gi) ? undefined : 'Invalid number format: only digits and + . - allowed';
public static url = (value) => !value || value.match(/^(\w+:)\/\//g) ? undefined : 'Invalid URL';
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment