Linked Questions

Popular Questions

Firebase: Email has been badly formatted

Asked by At

I'm using react-native, a formik form, yup validation and firebase authentication. However, I keep getting this error when I try to sign in:

createUser error: [Error: The email address is badly formatted.]

Here's my code: Firebase API:

export const signInUser = (email, password) => {
console.log('signInUser has been called')
firebase.auth().signInWithEmailAndPassword(email.trim(), password)
    .catch((error) => console.log('signIn error: ', error));
    if (email==""){
        console.log('email empty')
    if (password==""){
        console.log('password empty')
    if (email=="[email protected]"){
        console.log('email not empty')


Sign In Screen:

    FirebaseAPI.createUser(, this.state.password)

    FirebaseAPI.signInUser(, this.state.password)


          initialValues={{ email: '', password:'' }} 
          onSubmit={(values: FormValues, formikBag: FormikActions<FormValues>) =>
                    this.handleSubmit(values, formikBag)}
          validationSchema= {yupObject().shape({
                    email: yupString()
                    .email("Inavlid email address")
                    .required("This field is required"),
                    password: yupString()
                      .min(8, "Password must be longer than 8 characters")
                      .required("This field is required")
        render={(formikBag: FormikProps<FormValues>) => this.renderForm(formikBag)}

This is the result after logging the values:

[09:39:16] signInUser has been called
[09:39:16] email empty
[09:39:16] password empty
[09:39:16] signIn error:  [Error: The email address is badly formatted.]

Logging the actual values would give no result so I opted to check if the strings were empty, and it appears that they are. However, when I remove the formik form and use regular Input fields with no validation, everything works fine.

Related Questions