Form validation with yup - how to strip a field after validating it?

23 views Asked by At

On a vue.js web app I'm working on I need to be able to create passwords across multiple pages. For the form validation - which vee-validate and yup are used for -, I created a composable which adds a password field with a confirmation one to a form:

export const usePasswordSchema = () => ({
  password: string().required("Password required").password(),
  confirmPassword: string().oneOf([ref("password")], "Passwords do not match"),
})

But as it is right now, the value of confirmPassword field gets passed to the values object - used in the handleSubmit handler - as well, which I would have to filter out individually for every form that processes passwords. So added strip to this field, which is supposed to remove the field, but unfortunately this also disabled the validation, allowing for any value to be entered.

My question is, is there a way to have a value validated and then immediately stripped from the values object, without having to strip it manually afterwards?

0

There are 0 answers