Here's the code:
{
label: "Name",
name: "name",
placeholder: 'Name',
type: "text",
rule: yup.string()
.required('Name is a required field')
.matches(/^[a-zA-Z0-9]+$/, '* This field cannot contain white space and special character'),
},
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?
I tried to do like this:
!/^[a-zA-Z0-9]+$/
but I'm getting an error which is this
The argument of type 'boolean' is not assignable to parameter of type 'RegExp'.