This package will provide a PhoneValidation component which validate different countries phone number as per maximum digits
npm install react-native-phone-validation
import React, { useState } from 'react';
import { Button, SafeAreaView } from 'react-native';
import PhoneValidation, {
checkPhoneValidation,
} from 'react-native-phone-validation';
const App = () => {
const [country, setCountry] = useState();
const [value, setValue] = useState();
return (
<SafeAreaView style={{ flex: 1 }}>
<PhoneValidation setCountry={setCountry} setValue={setValue} />
<Button
title="Check"
onPress={() => {
const result = checkPhoneValidation(country, value);
console.log(result);
}}
/>
</SafeAreaView>
);
};
export default App;
- setCountry : will set the selected country from dropdown
- setValue : will set the value entered in textinput
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library