How To Validate Select Option With Vee-Validate How To Validate Select Option With Vee-Validate vue.js vue.js

How To Validate Select Option With Vee-Validate


v-model="client.category" 

v-validate doesn't work if your v-model is a complex object. I'd use strings/numbers to tie option->select and then use some function to model rest of the attributes in the object.


Well I found this question and I know the answer would be the right on a year ago. But right now yes, we can validate an object in a select. So for those select using and object as a value you can add the required validation as a custom one like this:

extend('objectNotEmpty', {  validate: (value) => {    if (Object.keys(value).length > 0) {      return true;    }    return i18n.t('GENERAL_VALIDATION_MESSAGES_REQUIRED');  },});

And of course add 'objectNotEmpty' in the list of the rules in your ValidationProvider