title: Yup validation for loginID with dynamic data type(either email or phone number)
body: <p>I am trying to implement login functionality using Formik and Yup. This is my current schema</p>
  
  <pre><code>let loginSchema = yup.object().shape({loginId:
  yup
    .string()
    .email("That doesn't look like a valid email")
    .required("This field is required."),password: yup.string().required("This field is required."),});
  </code></pre>
  
  <p>But my loginId can either be a phone number or email. So, how do i add the validation based on the type of field that has been entered in the form. If its an email, trigger validation for email or if its phone number, i want to validate it against a regex.</p>