11import lodashIsEmpty from 'lodash/isEmpty' ;
2- import React from 'react' ;
2+ import React , { useCallback } from 'react' ;
33import type { OnyxEntry } from 'react-native-onyx' ;
44import DatePicker from '@components/DatePicker' ;
55import FormProvider from '@components/Form/FormProvider' ;
66import InputWrapper from '@components/Form/InputWrapper' ;
7- import type { FormOnyxValues } from '@components/Form/types' ;
7+ import type { FormInputErrors , FormOnyxValues } from '@components/Form/types' ;
88import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations' ;
99import useLocalize from '@hooks/useLocalize' ;
1010import useOnyx from '@hooks/useOnyx' ;
@@ -91,6 +91,17 @@ function IOURequestStepDate({
9191 navigateBack ( ) ;
9292 } ;
9393
94+ const validate = useCallback (
95+ ( values : FormOnyxValues < typeof ONYXKEYS . FORMS . MONEY_REQUEST_DATE_FORM > ) => {
96+ const errors : FormInputErrors < typeof ONYXKEYS . FORMS . MONEY_REQUEST_DATE_FORM > = { } ;
97+ if ( ! values [ INPUT_IDS . MONEY_REQUEST_CREATED ] || values [ INPUT_IDS . MONEY_REQUEST_CREATED ] === '' ) {
98+ errors [ INPUT_IDS . MONEY_REQUEST_CREATED ] = translate ( 'common.error.fieldRequired' ) ;
99+ }
100+ return errors ;
101+ } ,
102+ [ translate ] ,
103+ ) ;
104+
94105 return (
95106 < StepScreenWrapper
96107 headerTitle = { translate ( 'common.date' ) }
@@ -107,6 +118,7 @@ function IOURequestStepDate({
107118 submitButtonText = { translate ( 'common.save' ) }
108119 enabledWhenOffline
109120 shouldHideFixErrorsAlert
121+ validate = { validate }
110122 >
111123 < InputWrapper
112124 InputComponent = { DatePicker }
0 commit comments