@@ -16,7 +16,7 @@ export default function useDateInput({
1616 value : Date | undefined
1717 validRange : ValidRangeType | undefined
1818 inputMode : 'start' | 'end'
19- onValidationError ?: ( ( error : string ) => void ) | undefined
19+ onValidationError ?: ( ( error : string | null ) => void ) | undefined
2020} ) {
2121 const { isDisabled, isWithinValidRange, validStart, validEnd } =
2222 useRangeChecker ( validRange )
@@ -43,7 +43,7 @@ export default function useDateInput({
4343 ( ) => 'notAccordingToDateFormat'
4444 ) ( inputFormat )
4545 setError ( inputError )
46- onValidationError ( inputError )
46+ onValidationError && onValidationError ( inputError )
4747 return
4848 }
4949
@@ -55,7 +55,7 @@ export default function useDateInput({
5555 if ( isDisabled ( finalDate ) ) {
5656 const inputError = getTranslation ( locale , 'dateIsDisabled' )
5757 setError ( inputError )
58- onValidationError ( inputError )
58+ onValidationError && onValidationError ( inputError )
5959 return
6060 }
6161 if ( ! isWithinValidRange ( finalDate ) ) {
@@ -86,12 +86,12 @@ export default function useDateInput({
8686 ]
8787 const inputError = errors . filter ( ( n ) => n ) . join ( ' ' )
8888 setError ( errors . filter ( ( n ) => n ) . join ( ' ' ) )
89- onValidationError ( inputError )
89+ onValidationError && onValidationError ( inputError )
9090 return
9191 }
9292
9393 setError ( null )
94- onValidationError ( null )
94+ onValidationError && onValidationError ( null )
9595 if ( inputMode === 'end' ) {
9696 onChange ( finalDate )
9797 } else {
0 commit comments