-
Notifications
You must be signed in to change notification settings - Fork 24
Vuetify: DatePickerComponent
Mike Lyttle edited this page Jul 5, 2023
·
2 revisions
- Swap
<DatePickerComponent>for<HgDatePickerComponent>. - Swap
:valueand@update:valueprops forv-model. - The behaviour of validation has changed and been expanded.
- The component internally validates that dates entered via the text field are valid (having the correct format and corresponding to a real date). The model will see invalid dates as empty dates, but if you want to determine if an invalid date has been entered (e.g. to prevent form submission when the date has not deliberately been cleared), you can handle the
validity-updatedevent and store the value. This is a replacement for theis-date-validevent. - All other validations (required, minValue, maxValue) should be handled by the parent component.
- To trigger these validations, the
blurevent should be handled and$touch()should be called. - Information associated with the validations can be passed to
<HgDatePickerComponent>via thestateanderror-messagesprops. This will allow the component to display a red outline and error message for validations from the parent. -
<HgDatePickerComponent>has props formin-dateandmax-datewhich limit the options available in the picker. These should be used in conjunction with minValue and maxValue validations on the parent.
- To trigger these validations, the
- The component internally validates that dates entered via the text field are valid (having the correct format and corresponding to a real date). The model will see invalid dates as empty dates, but if you want to determine if an invalid date has been entered (e.g. to prevent form submission when the date has not deliberately been cleared), you can handle the
const dateOfBirthIsValid = ref(false);
const validations = computed(() => ({
dependent: {
dateOfBirth: {
required,
minValue: helpers.withMessage(
`Date must not be before ${minBirthdate.value.format()}`,
(value: string) =>
!value ||
DateWrapper.fromStringFormat(value).isAfter(
minBirthdate.value
)
),
maxValue: helpers.withMessage(
`Date must not be after ${maxBirthdate.format()}`,
(value: string) =>
!value ||
DateWrapper.fromStringFormat(value).isBefore(maxBirthdate)
),
},
},
}));
const v$ = useVuelidate(validations, { dependent });
<HgDatePickerComponent
id="dateOfBirth"
v-model="dependent.dateOfBirth"
data-testid="dateOfBirthInput"
:state="ValidationUtil.isValid(v$.dependent.dateOfBirth)"
:error-messages="
ValidationUtil.getErrorMessages(v$.dependent.dateOfBirth)
"
:min-date="minBirthdate"
:max-date="maxBirthdate"
@blur="v$.value.dependent.dateOfBirth.$touch()"
@validity-updated="dateOfBirthIsValid = $event"
/>
-
Developer Standard and Processes
-
Workstation Setup
-
IDE Configuration
-
Application Config
-
RedHat SSO Authorization Server
-
Known Issues