1.3.2 • Published 4 years ago

yup-phone v1.3.2

Weekly downloads
4,129
License
MIT
Repository
github
Last release
4 years ago

yup-phone MIT License

Build Status Commitizen friendly semantic-release codecov FOSSA Status Known Vulnerabilities Codacy Badge

Adds a phone number validation check to yup validator using google-libphonenumber which gives accurate validation checks.
Read more here libphonenumber.

Install

# npm install --save yup-phone
$ yarn add yup-phone

Usage

const phoneSchema = Yup.string().phone().required();
import * as Yup from "yup";
import "yup-phone";

// validate any phone number (defaults to India for country)
const phoneSchema = Yup.string()
  .phone()
  .required();

(async () => {
  console.log(await phoneSchema.isValid("9876543210")); // → true
})();
import * as Yup from "yup";
import "yup-phone";

// validate phone number loosely in the given region
const phoneSchema = Yup.string()
  .phone("IN")
  .required();

(async () => {
  console.log(await phoneSchema.isValid('+919876543210')); // → true
})();
import * as Yup from "yup";
import "yup-phone";

// validate phone number strictly in the given region
const phoneSchema = Yup.string()
  .phone("IN", true)
  .required();

(async () => {
  console.log(await phoneSchema.isValid("+919876543210")); // → true
})();

For more, check yup-phone.test.ts file.

Contributing

  • Uses Rollup for bundling.
  • Uses yarn for package management.
  • Files are minified using closure compiler.
  • Uses jest for testing.
  • Generates CJS, UMD, and ESM builds.
  • Use yarn version --major|--minor|--patch to version.
  • Use tslint and prettier for code formatting.
  • Uses semantic release for version.
  • Use yarn commit to create a standard commit interactively.
$ yarn build # Build for production
$ yarn test # Run tests

License

MIT.

FOSSA Status

1.3.2

4 years ago

1.3.1

4 years ago

1.2.19

4 years ago

1.2.18

4 years ago

1.2.17

4 years ago

1.2.16

5 years ago

1.2.15

5 years ago

1.2.14

5 years ago

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.0

5 years ago

1.2.1

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago