1- // @flow
21import { Temporal } from '@js-temporal/polyfill' ;
32import { convertLocalToIsoCalendar } from 'capture-core/utils/converters/date' ;
43import { isValidDateTime } from './dateTimeValidator' ;
54
6- function isValidDateTimeWithEmptyCheck ( value : ? { date ?: ? string , time ?: ? string } , internalError ?: ? { error : ? string , errorCode : ? string } ) {
5+ function isValidDateTimeWithEmptyCheck ( value : { date ?: string | null , time ?: string | null } | null | undefined , internalError ?: { error ?: string | null | undefined , errorCode ?: string | null | undefined } | null | undefined ) {
76 return isValidDateTime ( value , internalError ) ;
87}
9- /* eslint-disable complexity */
10- const convertDateTimeToIsoTemporal = ( value : ? Object ) => {
8+
9+ const convertDateTimeToIsoTemporal = ( value : any | null | undefined ) => {
1110 if ( ! value || ! value . date || ! value . time ) {
1211 return null ;
1312 }
@@ -46,15 +45,14 @@ const convertDateTimeToIsoTemporal = (value: ?Object) => {
4645} ;
4746
4847export const getDateTimeRangeValidator = ( invalidDateTimeMessage : string ) =>
49- // eslint-disable-next-line complexity
50- ( value : { from ?: ?Object , to ?: ?Object } , internalComponentError ?: ?{ fromDateError : ?{ error : ?string , errorCode : ?string } , toDateError : ?{ error : ?string , errorCode : ?string } } ) => {
48+ ( value : { from ?: any | null , to ?: any | null } , internalComponentError ?: { fromDateError ?: { error ?: string | null | undefined , errorCode ?: string | null | undefined } | null | undefined , toDateError ?: { error ?: string | null | undefined , errorCode ?: string | null | undefined } | null | undefined } | null | undefined ) => {
5149 if ( ! value ?. from && value ?. to ) {
5250 return {
5351 valid : false ,
5452 errorMessage : { from : invalidDateTimeMessage , to : invalidDateTimeMessage } ,
5553 } ;
5654 }
57- const errorResult = [ ] ;
55+ const errorResult : any [ ] = [ ] ;
5856 if ( ! isValidDateTimeWithEmptyCheck ( value ?. from , internalComponentError ?. fromDateError ) . valid ) {
5957 errorResult . push ( { from : invalidDateTimeMessage } ) ;
6058 }
@@ -66,7 +64,6 @@ export const getDateTimeRangeValidator = (invalidDateTimeMessage: string) =>
6664 if ( errorResult . length > 0 ) {
6765 return {
6866 valid : false ,
69- // $FlowFixMe[exponential-spread] automated comment
7067 errorMessage : errorResult . reduce ( ( map , error ) => ( { ...map , ...error } ) , { } ) ,
7168 } ;
7269 }
0 commit comments