Hi, I have an issue with the combined phone/email ...
# support-questions-legacy
a
Hi, I have an issue with the combined phone/email field. On some browsers the autocomplete adds an extra space at the end of the email address and then when trying to continue the user gets an error that the email is invalid. Did anyone encounter this issue or has an idea how to resolve it? Thanks
r
hey @adigutner
try this when you do thirdpartypasswordless.init on the frontend
Copy code
ts
ThirdPartyPasswordless.init({
    contactMethod: "EMAIL_OR_PHONE",
    validateEmailAddress: async function (value) {
        if (typeof value !== "string") {
            return "GENERAL_ERROR_EMAIL_OR_PHONE_NON_STRING";
        }

        value = value.trim();

        const defaultEmailValidatorRegexp =
            // eslint-disable-next-line no-useless-escape
            /^(([^<>()\[\]\\.,;:\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,}))$/;
        // We check if the email syntax is correct
        // As per https://github.com/supertokens/supertokens-auth-react/issues/5#issuecomment-709512438
        // Regex from https://stackoverflow.com/a/46181/3867175

        if (value.match(defaultEmailValidatorRegexp) === null) {
            return "GENERAL_ERROR_EMAIL_OR_PHONE_INVALID";
        }

        return undefined;

    }
})
This is largely the default logic for how the email is validated on the frontend, with an extra trim() function call added to it
hey @adigutner
Hey! I have made the fix, until the tests finish running (about 1-2 hours), you can try out the new version by doing:
Copy code
npm i git+https://github.com:supertokens/supertokens-auth-react.git#0.25
and then you shouldn't need to give a custom validateEmailAddress nor validatePhoneNumber function
a
Awesome thank you so much!
r
hey @adigutner i have released a new version -> 0.25.1.
Please use that
5 Views