Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
react-native-mask-text
Advanced tools
This is a library to mask Text and Input components in React Native and Expo (Android, iOS and Web).
This package was created based on other libraries of React Native text mask, with the goal of meeting the need of having a package to be used with all React Native contexts (multi-platform concept) and also be maintained currently. You can read this blog post on Substack to see more information about the creation to the current moment of this package.
yarn add react-native-mask-text
Pattern used in masked components:
9
- accept digit.A
- accept alpha.S
- accept alphanumeric.Ex: AAA-9999
Component similar with <TextInput />
but with custom mask option.
import { StyleSheet } from "react-native";
import { MaskedTextInput } from "react-native-mask-text";
//...
<MaskedTextInput
mask="AAA-9999"
onChangeText={(text, rawText) => {
console.log(text);
console.log(rawText);
}}
style={styles.input}
/>;
//...
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
},
});
Component similar with <Text />
but with custom mask option.
import { MaskedText } from "react-native-mask-text";
//...
<MaskedText mask="99/99/9999">30081990</MaskedText>;
These options only are used if you use prop type="date"
in your component:
Option | Type | Mandatory | Default Value | Description |
---|---|---|---|---|
dateFormat | string | No | yyyy/mm/dd | Date Format |
Component similar with <TextInput />
but with date mask option.
import { StyleSheet } from "react-native";
import { MaskedTextInput } from "react-native-mask-text";
//...
<MaskedTextInput
type="date"
options={{
dateFormat: 'YYYY/DD/MM',
}}
onChangeText={(text, rawText) => {
console.log(text);
console.log(rawText);
}}
style={styles.input}
keyboardType="numeric"
/>
//...
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
},
});
These options only are used if you use prop type="time"
in your component:
Option | Type | Mandatory | Default Value | Description |
---|---|---|---|---|
timeFormat | string | No | HH:mm:ss | Time Format |
Component similar with <TextInput />
but with time mask option.
import { StyleSheet } from "react-native";
import { MaskedTextInput } from "react-native-mask-text";
//...
<MaskedTextInput
type="time"
options={{
timeFormat: 'HH:mm:ss', // or 'HH:mm'
}}
onChangeText={(text, rawText) => {
setMaskedValue(text)
setUnmaskedValue(rawText)
}}
style={styles.input}
keyboardType="numeric"
/>
//...
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
},
});
These options only are used if you use prop type="currency"
in your component:
Option | Type | Mandatory | Default Value | Description |
---|---|---|---|---|
prefix | string | No | null | String to prepend |
decimalSeparator | string | No | null | Separation for decimals |
groupSeparator | string | No | null | Grouping separator of the integer part |
precision | number | No | 0 | Precision for fraction part (cents) |
groupSize | number | No | 3 | Primary grouping size of the integer part |
secondaryGroupSize | number | No | null | Secondary grouping size of the integer part |
fractionGroupSeparator | string | No | null | Grouping separator of the fraction part |
fractionGroupSize | number | No | null | Grouping size of the fraction part |
suffix | string | No | null | String to append |
Component similar with <TextInput />
but with currency mask option.
import { StyleSheet } from "react-native";
import { MaskedTextInput } from "react-native-mask-text";
//...
<MaskedTextInput
type="currency"
options={{
prefix: '$',
decimalSeparator: '.',
groupSeparator: ',',
precision: 2
}}
onChangeText={(text, rawText) => {
console.log(text);
console.log(rawText);
}}
style={styles.input}
keyboardType="numeric"
/>
//...
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
},
});
Component similar with <Text />
but with currency mask option.
import { MaskedText } from "react-native-mask-text";
//...
<MaskedText
type="currency"
options={{
prefix: '$',
decimalSeparator: '.',
groupSeparator: ',',
precision: 2
}}
>
5999
</MaskedText>;
mask
functionFunction used to mask text.
import { mask } from "react-native-mask-text";
const code = mask("ABC1234","AAA-9999") // return ABC-1234
unMask
functionFunction used to remove text mask.
import { unMask } from "react-native-mask-text";
const code = unMask("ABC-1234") // return ABC1234
You can see an example app with Expo CLI here.
You can see a SignUp example on Expo Snack working with iOS, Mobile, and Web here.
See Contributing.md
The app's source code is made available under the MIT license. Some of the dependencies are licensed differently, with the BSD license, for example.
Akinn Rosa - Github - akinncar@hotmail.com
FAQs
A React Native and Expo library to mask text
The npm package react-native-mask-text receives a total of 11,701 weekly downloads. As such, react-native-mask-text popularity was classified as popular.
We found that react-native-mask-text demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.