title: Form Validation using Yup to check whether inputs value is equal or not
body: <p>I need to make a form validation using Yup to check input type <code>email1</code>, <code>email2</code>, <code>email3</code>, <code>email4</code> and <code>email5</code> in my React App.</p>
  
  <p>The rule of thumb is easy. Check those <code>emails</code> is in valid form and cannot have similar <code>emails</code> values. </p>
  
  <p>I am super new to Yup. So what I did is:</p>
  
  <pre><code>const message = 'Duplicate emails not allowed';
  const incorrect = 'Incorrect email format';
  
  const Schema = Yup.object().shape({
    email1: Yup.string()
      .email(incorrect)
      .oneOf([Yup.ref('email2'), null], message)
      .oneOf([Yup.ref('email3'), null], message)
      .oneOf([Yup.ref('email4'), null], message)
      .oneOf([Yup.ref('email5'), null], message),
    email2: Yup.string()
      .email(incorrect)
      .oneOf([Yup.ref('email1'), null], message)
      .oneOf([Yup.ref('email3'), null], message) 
      .oneOf([Yup.ref('email4'), null], message)
      .oneOf([Yup.ref('email5'), null], message),
    email3: Yup.string()
      .email(incorrect)
      .oneOf([Yup.ref('email1'), null], message)
      .oneOf([Yup.ref('email2'), null], message)
      .oneOf([Yup.ref('email4'), null], message)
      .oneOf([Yup.ref('email5'), null], message),
    email4: Yup.string()
      .email(incorrect)
      .oneOf([Yup.ref('email1'), null], message)
      .oneOf([Yup.ref('email2'), null], message)
      .oneOf([Yup.ref('email3'), null], message)
      .oneOf([Yup.ref('email5'), null], message),
    email5: Yup.string()
      .email(incorrect)
      .oneOf([Yup.ref('email1'), null], message)
      .oneOf([Yup.ref('email2'), null], message)
      .oneOf([Yup.ref('email3'), null], message)
      .oneOf([Yup.ref('email4'), null], message)
  });
  </code></pre>
  
  <p>The issue with this method is, it will also detect an error of duplicate emails even the input text is empty. How do I fix this? Is there any better way that I could implement? </p>
  
  <p>Thanks</p>