# validate-phone-number-react-native

> Phone number validation

Latest version **1.0.0** (published 2022-07-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install validate-phone-number-react-native
pnpm add validate-phone-number-react-native
yarn add validate-phone-number-react-native
bun add validate-phone-number-react-native
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-07-27 |
| First published | 2022-07-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Muhammed Ali Yıldırım |
| Maintainers | aliyildirim |
| Keywords | validate, phone, numbers |

## Links

- npm: https://www.npmjs.com/package/validate-phone-number-react-native
- Repository: https://github.com/aliyildirim1/validate-phone-number-react-native
- Homepage: https://github.com/aliyildirim1/validate-phone-number-react-native#readme
- Issues: https://github.com/aliyildirim1/validate-phone-number-react-native/issues
- npm.io page: https://npm.io/package/validate-phone-number-react-native

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-07-27

## README

# validate-phone-number-react-native

## Telephone Number Validation

Github Link : https://github.com/aliyildirim1/validate-phone-number-react-native

## Install

```
npm i validate-phone-number-react-native

```

## Example

```
import React, {useContext, useState} from 'react';
import {Button, View, StyleSheet, ToastAndroid, Keyboard} from 'react-native';

import Input from '../components/Input';
import COLORS from '../const/colors';

const App = ({navigation}) => {
  const [inputs, setInputs] = React.useState({
    phone: '',
  });
  const [errors, setErrors] = React.useState({
    phone: '',
  });
  const validate = () => {
    Keyboard.dismiss();
    const validatePhoneNumber = require('validate-phone-number-react-native');

    let phoneNumberIsValidated = validatePhoneNumber(inputs.phone);
    if (phoneNumberIsValidated) {
      ToastAndroid.show('Successful!', ToastAndroid.SHORT);
    } else {
      handleError('Please input valid phone number', 'phone');
    }
  };
  const handleOnChange = (text, input) => {
    setInputs(prevState => ({...prevState, [input]: text}));
  };

  const handleError = (errorMessage, input) => {
    setErrors(prevState => ({...prevState, [input]: errorMessage}));
  };

  return (
    <View style={styles.container}>
      <View style={styles.wrapper}>
        <Input
          onChangeText={text => handleOnChange(text, 'phone')}
          error={errors.phone}
          onFocus={() => {
            handleError(null, 'phone');
          }}
          keyboardType="numeric"
          label="Phone Number"
          placeholder="Enter your phone number"
        />
        <Button title="Validation" onPress={validate} />
        <View style={{flexDirection: 'row', marginTop: 20}}></View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: COLORS.white,
  },
  wrapper: {
    width: '80%',
  },
});

export default App;


```

---
_Source: https://npm.io/package/validate-phone-number-react-native · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
