AAE-45774 Show error for date fields if invalid format (#11886)

* AAE-45774 Show error for date fields if invalid format

* apply copilot suggestions
This commit is contained in:
Darren Thornton
2026-05-20 14:19:31 +05:30
committed by Anamika Dey
parent b1cec34f92
commit d3eda11a2e
2 changed files with 20 additions and 0 deletions
@@ -82,6 +82,11 @@
[startAt]="valueDate"
[ngClass]="{ 'cdk-visually-hidden': !editable || isReadonlyProperty}"
/>
@if (cardViewDateTimeControl.hasError('matDatepickerParse')) {
<mat-error>
{{ 'FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT' | translate: { format: property.format ?? '' } }}
</mat-error>
}
</mat-form-field>
} @else {
<mat-form-field class="adf-property-field adf-dateitem-editable" [floatLabel]="property.default ? 'always' : null">
@@ -459,6 +459,21 @@ describe('CardViewDateItemComponent', () => {
expect(component.cardViewDateTimeControl.value).not.toBeNull();
});
it('should render error message when manual input has invalid date format', async () => {
fixture.detectChanges();
const manualInput = await testingUtils.getMatInputByDataAutomationId('datepicker-manual-input-dateKey');
await manualInput.setValue('not-a-date');
await manualInput.blur();
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
expect(component.cardViewDateTimeControl.invalid).toBeTrue();
const formField = await testingUtils.getMatFormFieldByCSS('.adf-dateitem-editable');
expect(await formField.getTextErrors()).toContain('FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT');
});
it('should clear the form control value when onDateClear is called', () => {
fixture.detectChanges();