vuetify-datetime-picker icon indicating copy to clipboard operation
vuetify-datetime-picker copied to clipboard

Validation

Open jscottwillems opened this issue 4 years ago • 4 comments

Having trouble finding a way to validate this component. If I try to use the "rules" prop on either the datePickerProps or timePickerProps it breaks the code. Is there an existing prop for this component for passing in validation rules or is this something that has yet to be handled?

jscottwillems avatar Jul 29 '20 14:07 jscottwillems

If it can help you, i did the following on my project:

 <ValidationProvider v-slot="{ errors }" name="Datetime" rules="required">
                                                    <v-datetime-picker
                                                        :error-messages="errors"
                                                        :text-field-props="{dense: true, prependIcon: 'event'}"
                                                        :date-picker-props="dateProps"
                                                        :time-picker-props="timeProps"
                                                        label="Date & Time"
                                                        v-model="selectedEventLocal.datetime">
                                                    </v-datetime-picker>
                                                </ValidationProvider>

But to do this (:error-messages) i had to fork the repo and do this: code

Hope it helps.

devstack-be avatar Jul 29 '20 18:07 devstack-be

Thanks, bro @devstack-be, it did help me

airrakedev avatar Aug 15 '20 15:08 airrakedev

For others who is looking for validation you can just add :textFieldProps="{ rules: [v => !!v || "You have to select a date!"] }" as an example,

atle-granlund avatar Dec 13 '20 23:12 atle-granlund

The option above with a simple rule is working fine. In Vuetify components it's possible to use a method to validate more complex rules. Is it possible to use a rule with this component ? If not, how to validate complex validation rules ?

tonybelloni avatar Mar 11 '23 00:03 tonybelloni