yup text validation code example
Example 1: yup only characters regex validation react
yup.string()
.required("Please enter the required field")
.matches(/^[aA-zZ\s]+$/, "Only alphabets are allowed for this field ")
Example 2: yup npm
npm i yup --save