How do I dynamically set validations fields in vuelidate How do I dynamically set validations fields in vuelidate vue.js vue.js

How do I dynamically set validations fields in vuelidate


you need a dynamic validation schema

validations () {  return {    if (!this.select === 'company') {      company_name: { required },      company_position_title: { required }    }    // other validations  }}

More info: Dynamic validation schema


Another way is using requiredIf

itemtocheck: {  requiredIf: requiredIf(function () {    return this.myitem !== 'somevalue'  }),  minLength: minLength(2) },