Skip to content

Commit abeac15

Browse files
fix types for TextField validate props (#3160)
* fix types for TextField `validate` props * Fix PR TS errors --------- Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 430c875 commit abeac15

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

demo/src/screens/componentScreens/NumberInputScreen.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const NumberInputScreen = () => {
111111
if (currentData.current?.type === 'valid') {
112112
return currentData.current.number > MINIMUM_PRICE;
113113
}
114+
return false;
114115
}, []);
115116

116117
const isWithinDiscountPercentage = useCallback(() => {
@@ -119,6 +120,7 @@ const NumberInputScreen = () => {
119120
currentData.current.number >= DISCOUNT_PERCENTAGE.min && currentData.current.number <= DISCOUNT_PERCENTAGE.max
120121
);
121122
}
123+
return false;
122124
}, []);
123125

124126
const validate = useMemo((): Incubator.TextFieldProps['validate'] => {

src/components/textField/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export enum Presets {
3737

3838
export type ValidationMessagePositionType = `${ValidationMessagePosition}` | ValidationMessagePosition;
3939

40-
export type Validator = Function | keyof typeof formValidators;
40+
export type Validator = ((value?: string) => boolean) | keyof typeof formValidators;
4141

4242
export interface FieldStateProps extends InputProps {
4343
validateOnStart?: boolean;

0 commit comments

Comments
 (0)