Vee-validate: Correct way to validate certain fields programmatically?

Created on 4 May 2017  ·  3Comments  ·  Source: logaretm/vee-validate

I would like to validate most fields automatically and only validate certain fields when $validator.validateAll() is called.

Currently, it's possible to achieve this by setting data-vv-validate-on="none" on the inputs that I want to validate manually, but this seems a bit hacky, especially since using an empty value for the property doesn't work.

Is there a better way to do this?

❔ question

Most helpful comment

It was hacky, You can use the .disable modifier introduced in rc.1 which should disable all automatic validations for that field.

<input type="text" name="email" v-validate.disable="'required|email'">

https://jsfiddle.net/acyxrwf5/

Maybe also adding a global config to save you from adding .disabled on each field will be welcomed.

All 3 comments

It was hacky, You can use the .disable modifier introduced in rc.1 which should disable all automatic validations for that field.

<input type="text" name="email" v-validate.disable="'required|email'">

https://jsfiddle.net/acyxrwf5/

Maybe also adding a global config to save you from adding .disabled on each field will be welcomed.

Thanks, the modifier is exactly what I was looking for, it's nice and concise. Currently, I couldn't find it anywhere in the documentation, but I assume it'll be added once the next version ships. In that case I think it's safe to close this issue as the problem is already resolved.

Yep its not documented yet. Will add it once I figure where to document it 🤔

Was this page helpful?
0 / 5 - 0 ratings