Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pre-validate masked input #56462

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-advanced-input-mask (1.2.1):
- react-native-advanced-input-mask (1.3.0-beta.0):
- DoubleConversion
- ForkInputMask (~> 7.3.2)
- glog
Expand Down Expand Up @@ -3351,7 +3351,7 @@ SPEC CHECKSUMS:
React-logger: 26155dc23db5c9038794db915f80bd2044512c2e
React-Mapbuffer: ad1ba0205205a16dbff11b8ade6d1b3959451658
React-microtasksnativemodule: e771eb9eb6ace5884ee40a293a0e14a9d7a4343c
react-native-advanced-input-mask: 22e3bd2a0f38fada50b475c98bf39d39053097a3
react-native-advanced-input-mask: d4067fd7bd3031ac543c02fda29864c70a0b9bcb
react-native-airship: e10f6823d8da49bbcb2db4bdb16ff954188afccc
react-native-app-logs: ee32b6e80bf8d1b883dfc5ac96efa7c1bd9a06a5
react-native-blob-util: 221c61c98ae507b758472ac4d2d489119d1a6c44
Expand Down
15 changes: 4 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"react-fast-pdf": "^1.0.22",
"react-map-gl": "^7.1.3",
"react-native": "0.76.3",
"react-native-advanced-input-mask": "1.2.1",
"react-native-advanced-input-mask": "1.3.0-beta.0",
"react-native-android-location-enabler": "^2.0.1",
"react-native-app-logs": "0.3.1",
"react-native-blob-util": "0.19.4",
Expand Down
1 change: 1 addition & 0 deletions src/components/AmountWithoutCurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function AmountWithoutCurrencyInput(
type="mask"
mask={`[09999999]${separator}[09]`}
allowedKeys="0123456789.,"
validationRegex={'^(?!.*[.,].*[.,])\\d{0,8}(?:[.,]\\d{0,2})?$'}
// On android autoCapitalize="words" is necessary when keyboardType="decimal-pad" or inputMode="decimal" to prevent input lag.
// See https://github.com/Expensify/App/issues/51868 for more information
autoCapitalize="words"
Expand Down
3 changes: 3 additions & 0 deletions src/components/TextInput/BaseTextInput/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ type CustomBaseTextInputProps = {
/** A set of permitted characters for the input */
allowedKeys?: MaskedTextInputOwnProps['allowedKeys'];

/** A regular expression to validate the input before proceeding to masking stage */
validationRegex?: MaskedTextInputOwnProps['validationRegex'];

/** Whether the input should be enforced to be uncontrolled. Default is `false` */
uncontrolled?: boolean;
};
Expand Down
Loading