diff --git a/src/process/validation/rules/__tests__/validateDate.test.ts b/src/process/validation/rules/__tests__/validateDate.test.ts index 63cb5609..be023f89 100644 --- a/src/process/validation/rules/__tests__/validateDate.test.ts +++ b/src/process/validation/rules/__tests__/validateDate.test.ts @@ -73,44 +73,12 @@ it('Validating a textField calendar picker component with no data will return nu expect(result).to.equal(null); }); -it('Validating a textField calendar picker component with an invalid date string value will return a FieldError', async () => { +it('Textfield calendar picker component date values should not be validated and return null', async () => { const component = calendarTextField; const data = { component: 'hello, world!', }; const context = generateProcessorContext(component, data); const result = await validateDate(context); - expect(result).to.be.instanceOf(FieldError); - expect(result?.errorKeyOrMessage).to.equal('invalidDate'); -}); - -it('Validating a textField calendar picker component with an valid date string value will return null', async () => { - const component = calendarTextField; - const data = { - component: '2023-03-09T12:00:00-06:00', - }; - const context = generateProcessorContext(component, data); - const result = await validateDate(context); - expect(result).to.equal(null); -}); - -it('Validating a textField calendar picker component with an invalid Date object will return a FieldError', async () => { - const component = calendarTextField; - const data = { - component: new Date('Hello, world!'), - }; - const context = generateProcessorContext(component, data); - const result = await validateDate(context); - expect(result).to.be.instanceOf(FieldError); - expect(result?.errorKeyOrMessage).to.equal('invalidDate'); -}); - -it('Validating a textField calendar picker component with a valid Date object will return null', async () => { - const component = calendarTextField; - const data = { - component: new Date(), - }; - const context = generateProcessorContext(component, data); - const result = await validateDate(context); - expect(result).to.equal(null); + expect(result).to.be.equal(null); }); diff --git a/src/process/validation/rules/validateDate.ts b/src/process/validation/rules/validateDate.ts index 1d740963..0a14ccc9 100644 --- a/src/process/validation/rules/validateDate.ts +++ b/src/process/validation/rules/validateDate.ts @@ -6,12 +6,8 @@ const isValidatableDateTimeComponent = (obj: any): obj is DateTimeComponent => { return !!obj && !!obj.type && obj.type === 'datetime'; }; -const isValidatableTextFieldComponent = (obj: any): obj is TextFieldComponent => { - return !!obj && !!obj.type && obj.widget && obj.widget.type === 'calendar'; -}; - const isValidatable = (component: any) => { - return isValidatableDateTimeComponent(component) || isValidatableTextFieldComponent(component); + return isValidatableDateTimeComponent(component); }; export const shouldValidate = (context: ValidationContext) => {