Skip to content Skip to sidebar Skip to footer

Yup.validate Only Returns Single Field In Errors Array

I am trying to add yup in an angular7 project. I have added it successfully to my component. readonly optionalRequiredSchema = yup.object().shape({ ['@name']: yup.string().re

Solution 1:

Yup validate function accept second argument options. Pass {abortEarly: false} will fix your issue

  validateData() {
    this.optionalRequiredSchema.validate(this.allData, {abortEarly: false})
      .then(
        (data) => console.log(data)
      ).catch(err => {
        console.log(err);
        this.showToast('top-right', 'danger', JSON.stringify(err.errors))


      })
  }

Post a Comment for "Yup.validate Only Returns Single Field In Errors Array"