kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

returns a single message at a time #187

Open xingangsun opened 8 years ago

xingangsun commented 8 years ago

How can I returns the first message for a vue-validator field. Useful when trying to display a single message at a time.

kazupon commented 8 years ago

Thank you for your feedback!!

Useful when trying to display a single message at a time.

Sorry, I could understand. Can you provide the minimum example code please ?

xingangsun commented 8 years ago

I have two forms, for example, if the first check is not passed, only to return to the first error information, the second form doesn't need to check again until the first check passed

BrainOverfloW commented 8 years ago

I've ran into the same need. My use case was a field that is required and needs to be a number. When left empty I want just the required message displayed. If the field is filled out but not a number I want to display a error that a number needs to be entered.

sithuaung commented 8 years ago

Yes I have the same use-case like this.

vue-validator

I don't want to show two error messages at the same time.

emondora commented 8 years ago

I've ran into the same need too!

NiltiakSivad commented 8 years ago

Echoing everything everyone else has already said on this thread. This would be a nice feature if it's not already supported.

This could be easily solved if Vue.js had a better way of doing "else-if". Unfortunately, Evan recommended this method which is pretty ugly and not maintainable if you have a lot of validations: https://forum.vuejs.org/topic/1107/%E8%AF%B7%E9%97%AE%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0-elseif-%E7%9A%84%E6%95%88%E6%9E%9C/2

wuyiw commented 8 years ago

a workaround: <span v-text="$validatorName.fieldName.errors ? $validatorName.fieldName.errors[0].message : ''"></span> hope the single-error-msg feature to be added.

robertmylne commented 8 years ago

Second this feature.