I am using the following yup:
export const validationSchema = Yup.object().shape({
password: Yup.string()
.required('Password is required')
.matches(
/^[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/,
'Need one special character',
),
confirmPassword: Yup.string()
.oneOf([Yup.ref('password'), null], 'Passwords must match')
.required('Password confirm is required'),
});
to validate if there is one special character in password string.
@ => valid
@a => invalid
a@ => invalid
aa => invalid, of course
I also test the regex pattern online to make sure this pattern will catch any special character in string I wonder it could be yup bug or I do something wrong