Link Search Menu Expand Document (external link)

Home > @department-of-veterans-affairs/va-forms-system-core > isValidEmail

isValidEmail variable

This function is used to validate an email address, while returning error messages if an email is invalid. The logic is as follows:

  1. Ensure the email address is a string. If it’s not, return an error message 2. Ensure that one of the following is true, else output an error message: 2a. The field is not required -AND- the field has no entered value 2b. The value in the field matches an email validation regular expression

Signature:

isValidEmail: <T>(emailString: T, props: FieldProps<T>) => ValidationFunctionResult<T>