From 9dea612a861cf27868ee2f930f6bff1831a37c49 Mon Sep 17 00:00:00 2001 From: sambhu Date: Tue, 6 Oct 2026 18:30:26 +0530 Subject: [PATCH] fix(dateTime): Updated the validation part --- .../field/date-time/date-time.component.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/angular-sdk-components/src/lib/_components/field/date-time/date-time.component.ts b/packages/angular-sdk-components/src/lib/_components/field/date-time/date-time.component.ts index 4c91c6cdb..2281b7134 100644 --- a/packages/angular-sdk-components/src/lib/_components/field/date-time/date-time.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/field/date-time/date-time.component.ts @@ -95,6 +95,12 @@ export class DateTimeComponent extends FieldBase implements OnInit, OnDestroy { } fieldOnDateChange(event: any) { + // owl picker emits null when the typed text can't be parsed; clear the input instead of defaulting to now + if (!event.value) { + this.fieldControl.setValue(''); + handleEvent(this.actionsApi, 'changeNblur', this.propName, ''); + return; + } // this comes from the date pop up if (typeof event.value === 'object') { // convert date to pega "date" format @@ -104,4 +110,25 @@ export class DateTimeComponent extends FieldBase implements OnInit, OnDestroy { } handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value); } + + override getErrorMessage() { + // look for validation messages for json, pre-defined or just an error pushed from workitem (400) + if (this.fieldControl.hasError('message')) { + return this.angularPConnectData.validateMessage ?? ''; + } + + if (this.fieldControl.hasError('required')) { + return 'You must enter a value'; + } + + if (this.fieldControl.hasError('owlDateTimeParse')) { + return `${this.fieldControl.errors?.['owlDateTimeParse'].text} is not a valid date time value`; + } + + if (this.fieldControl.errors) { + return 'Invalid date time value'; + } + + return ''; + } }