use yup to validate password code example
Example: yup password validation
import * as Yup from 'yup';
validationSchema: Yup.object({
password: Yup.string().required('Password is required'),
passwordConfirmation: Yup.string()
.oneOf([Yup.ref('password'), null], 'Passwords must match')
});