how to validate a javascript date object emited by a component with 3 inputs (DD, MM, YYYY)
Versions
- vee-validate: 2.2.0
- vue: 2.6.10
Describe the bug
Its not realy a bug, but a question. I've a compontent FormDate with 3 inputs, and a Date value.
Is it possible to add the v-validate directive on my component ? ex :
<form-date v-validate="'required'" v-model="myBirthDay">
Or my first idea was to add an hidden input, but i dont think its a good way.
Demo link https://codepen.io/erwanpoupard/pen/MRpwXP?editors=1111
Yes, it is possible, The date rules do accept a JS date object, it won't be parsed and it will bypass the date_format constraints since it would be a valid date obj. Generally, vee-validate does not have constraints on the type of the value being validated, it can be anything, not just strings.
The caveats would be dealing with the invalid states, for example, someone inputs a 0 or empties one of the inputs, negative values. You would need to emit either null to trigger required or date object with NaN time.