diff --git a/client/modules/User/components/ResetPasswordForm.jsx b/client/modules/User/components/ResetPasswordForm.jsx index ed724b5f..6ed00455 100644 --- a/client/modules/User/components/ResetPasswordForm.jsx +++ b/client/modules/User/components/ResetPasswordForm.jsx @@ -17,6 +17,7 @@ function ResetPasswordForm(props) { id="email" {...domOnlyProps(email)} /> + {email.touched && email.error && {email.error}}
domProps; /* eslint-enable */ +// eslint-disable-next-line max-len +const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\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,}))$/i; + function validateNameEmail(formProps, errors) { if (!formProps.username) { errors.username = 'Please enter a username.'; @@ -28,7 +31,7 @@ function validateNameEmail(formProps, errors) { errors.email = 'Please enter an email.'; } else if ( // eslint-disable-next-line max-len - !formProps.email.match(/^(([^<>()[\]\\.,;:\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,}))$/i)) { + !formProps.email.match(EMAIL_REGEX)) { errors.email = 'Please enter a valid email address.'; } } @@ -79,3 +82,14 @@ export function validateSignup(formProps) { return errors; } +export function validateResetPassword(formProps) { + const errors = {}; + if (!formProps.email) { + errors.email = 'Please enter an email.'; + } else if ( + // eslint-disable-next-line max-len + !formProps.email.match(EMAIL_REGEX)) { + errors.email = 'Please enter a valid email address.'; + } + return errors; +}