Add validator for email address format

This commit is contained in:
Kimmo Puputti 2017-10-03 11:26:59 +03:00
parent de629316d4
commit a897c71afd

View file

@ -59,3 +59,12 @@ export const bookingDatesRequired = (inValidStartDateMessage, inValidEndDateMess
return VALID;
}
};
// Source: http://www.regular-expressions.info/email.html
// See the link above for an explanation of the tradeoffs.
const EMAIL_RE = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
export const emailFormatValid = message =>
value => {
return value && EMAIL_RE.test(value) ? VALID : message;
};