0
  1. If user enters in the input field 'company' or 'test' i want Yup to mark this as failed validation.

  2. If user enter companyThis or *test* (* === wild card), also want that to fail.

Can't seem to find that Yup has a method for this thing, so probably something custom?

Currently in Yup schema i have.

    const schema = yup.object().shape({
      username: yup
        .string()
        .min(4, 'User name to short')
        .matches(/^[A-Za-z0-9]+$/, 'Only numbers and letters are allowed')
        .required('Required'),
    });
Marius
  • 1,664
  • 2
  • 16
  • 28
  • Why not add one more `.matches(...)` with the appropriate regex? Do you require specific guidance for the regex bit? Okay, may be I jumped the gun with my first question. Please [check this](https://stackoverflow.com/a/59282340/13658816). `Yup.test` seems to be the appropriate one to be used here. – jsN00b Feb 08 '22 at 09:07
  • 1
    thank you got it, i was using test wrong initially – Marius Feb 08 '22 at 09:24

0 Answers0