score:3

You should try Yup like this.

const formikEnhancer = withFormik({
      validationSchema: Yup.object().shape({
        name: Yup.string().strict(true).lowercase('Name must be lowercase').matches(/^\S+$/, 'Name must not contain spaces').matches(/^(?:(?!\.).)*$\r?\n?/, 'Name must not contain period').max(10, 'Maximum of 10 characters')
          .required('Name is required!'),
         email: Yup.string().strict(true).lowercase('Email must be lowercase').required('Email is required!')
      })
    })

Related Query

More Query from same tag