Back to directory
ScottEAdams

payload plugin phone field

by ScottEAdams
v1
^1.1.18

From the author

Payload CMS plugin to add a phone number field

Installation

npm i payload-plugin-phone-field

12

Stars

0

Forks

0

Open Issues

3 years ago

Last Updated

1

Weekly Downloads

v1.0.6

npm Version

10.2 KB

Unpacked Size

1

Dependencies

GitHub stars

Trends appear after 7 days of data. Daily snapshots have not started yet.

npm weekly downloads

Trends appear after 7 days of data. Daily snapshots have not started yet.

Each point is npm's rolling 7-day download count.

Health Score

0/100Archived

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/559376777-root.svg)](https://payloaddirectory.dev/plugins/559376777-root)
HTML
<a href="https://payloaddirectory.dev/plugins/559376777-root"><img src="https://payloaddirectory.dev/badge/559376777-root.svg" alt="Payload Directory"></a>
Updated Nov 23, 2022Created Oct 29, 2022Published Nov 23, 2022

README

# payload-plugin-phone-field

Uses [react-phone-number-input](https://www.npmjs.com/package/react-phone-number-input) to add phone number fields to [PayloadCMS](https://payloadcms.com/).

## Installation

```
yarn add payload-plugin-phone-field
```
or
```
npm i payload-plugin-phone-field
```

## Usage

Really straightforward implementation:

```js
import { phoneField } from 'payload-plugin-phone-field'
Full README
# payload-plugin-phone-field

Uses [react-phone-number-input](https://www.npmjs.com/package/react-phone-number-input) to add phone number fields to [PayloadCMS](https://payloadcms.com/).

## Installation

```
yarn add payload-plugin-phone-field
```
or
```
npm i payload-plugin-phone-field
```

## Usage

Really straightforward implementation:

```js
import { phoneField } from 'payload-plugin-phone-field'

fields: [
    phoneField(
        {
            name: 'phone', // required
        }
    )
]
```

But you can also add any options that TextField accepts and any options that [PhoneNumberInput](https://catamphetamine.gitlab.io/react-phone-number-input/docs/index.html) accepts.

For example, add a label, required and validation plus only show 6 countries to choose from:
```js
fields: [
	phoneField(
		{
			name: 'phone', // required
			label: 'Contact Phone Number',
			required: true,
			validate: phoneIsValid
		},
		{ countries: ['DK', 'FI', 'NO', 'SE', 'GB', 'US'] }
	)
]
```

You can use your own validation function or one of the two included. You can read the rationale from [Nikolay Kuchumov](https://gitlab.com/catamphetamine/libphonenumber-js#using-phone-number-validation-feature).

```js
import { phoneIsValid, phoneIsPossible } from 'payload-plugin-phone-field'
```

Similar plugins