Giter VIP home page Giter VIP logo

yup-phone's Introduction

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

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();

console.log(phoneSchema.isValidSync("+919876543210")); // → true

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

Module Sizes

Destination: dist/yup-phone.umd.js
Bundle Size:  530.02 KB
Minified Size:  522.95 KB
Gzipped Size:  103.4 KB
Destination: dist/yup-phone.umd.min.js
Bundle Size:  503.58 KB
Minified Size:  501.25 KB
Gzipped Size:  102.53 KB
Destination: dist/yup-phone.esm.js
Bundle Size:  602 B
Minified Size:  603 B
Gzipped Size:  349 B
Destination: dist/yup-phone.cjs.js
Bundle Size:  902 B
Minified Size:  900 B
Gzipped Size:  474 B

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
$ yarn publish # Publish npm package (prompts for version)

License

MIT.

FOSSA Status

yup-phone's People

Contributors

abhisekp avatar dependabot-preview[bot] avatar uladzislau-kirychenka avatar fossabot avatar greenkeeper[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.