title: How do I not allow special characters and space in react hook using yup
body: <p>Here's the code:</p>
  <pre><code>{
        label: &quot;Name&quot;,
        name: &quot;name&quot;,
        placeholder: 'Name',
        type: &quot;text&quot;,
        rule: yup.string()
        .required('Name is a required field')
        .matches(/^[a-zA-Z0-9]+$/, '* This field cannot contain white space and special character'),
      },
  </code></pre>
  <p>What I'm trying to do is to restrict the input which does not allow any special characters and whitespace.  also how to validate the input while typing in yup?</p>
  <p>I tried to do like this:
  <code>!/^[a-zA-Z0-9]+$/</code>
  but I'm getting an error which is this</p>
  <p>The argument of type 'boolean' is not assignable to parameter of type 'RegExp'.</p>