Vee-validate: Component validation (Element-UI date-picker)

Created on 17 Oct 2017  Â·  5Comments  Â·  Source: logaretm/vee-validate

Versions:

  • VueJs: 2.5.2
  • Vee-Validate: 2.0.0-rc.19

Description:

I'm trying to get the validation work for date-picker component.
Tried following http://vee-validate.logaretm.com/examples.html#component-example
as well as date-format but it seems the format is always picked up wrong or I may be missing something.

Steps To Reproduce:

Open the sandbox and pick a date.
You get The date must be in the format DD-MM-YYYY. regardless of the picker format

Notes

Internally date-picker uses change event to propagate v-model changes. I saw that vee-validate requires an input event for custom components. Is there any way to change/work around that ?

✨ enhancement

Most helpful comment

yep, the custom parser didn't allow date objects, now if its a date object it checks if its a valid instance, and skips the rest of the checks and returns it, so the date rules should work fine.

Thanks for reporting this.

All 5 comments

If it uses v-model then it doesn't matter if its a component or a native input as vee-validate delegates the listening trigger to Vue, so it picks up the value correctly whenever it changes.

Now, it looks like the picker emits a Date instance rather than a string, which date_format isn't equipped to deal with (it validates strings). I guess I will mark this as an enhancement.

Thanks a lot @logaretm Is the enhancement going to work along with date_between ?

yep, the custom parser didn't allow date objects, now if its a date object it checks if its a valid instance, and skips the rest of the checks and returns it, so the date rules should work fine.

Thanks for reporting this.

Did this get applied to the 'before' rule? Ie. it's not working for my element (2.04) date element

Has this enhancement been released yet? I'm still getting "The [field] value is not valid." I'm on 2.0.9

Was this page helpful?
0 / 5 - 0 ratings