All Projects → abhisekp → yup-phone

abhisekp / yup-phone

Licence: MIT license
☎️ Adds a phone number validation check to yup validator using google-libphonenumber

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to yup-phone

Vue Phone Number Input
A phone number input made with Vue JS (format & valid phone number)
Stars: ✭ 407 (+85.84%)
Mutual labels:  phone, number
PhoneNumberKit
Android Kotlin library to parse and format international phone numbers. Country code picker.
Stars: ✭ 124 (-43.38%)
Mutual labels:  phone, number
Telephone number
Phone number validation for Ruby
Stars: ✭ 262 (+19.63%)
Mutual labels:  phone, number
React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (+103.65%)
Mutual labels:  phone, number
React Phone Number Input
React component for international phone number input
Stars: ✭ 725 (+231.05%)
Mutual labels:  phone, number
Libphonenumber Js
A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
Stars: ✭ 2,233 (+919.63%)
Mutual labels:  phone, number
Laravel Phone
Phone number functionality for Laravel
Stars: ✭ 1,806 (+724.66%)
Mutual labels:  phone, libphonenumber
phonenumber
With a given country and phone number, validate and format the MOBILE phone number to E.164 standard
Stars: ✭ 108 (-50.68%)
Mutual labels:  phone, number
DataTypes
Built-in data types
Stars: ✭ 34 (-84.47%)
Mutual labels:  number
example-objc
Codecov example for Xcode
Stars: ✭ 24 (-89.04%)
Mutual labels:  codecov
shrtn-it
A url shortener developed as a course completion project
Stars: ✭ 16 (-92.69%)
Mutual labels:  yup
bananapi-zero-ubuntu-base-minimal
BananaPi M2 Zero - Ubuntu Focal Base Minimal Image (Experimental) - U-Boot 2017.09 / Kernel 4.18.y / Kernel 4.19.y / Kernel 4.20.y / Kernel 5.3.y / Kernel 5.6.y / Kernel 5.7.y / Kernel 5.11.y
Stars: ✭ 77 (-64.84%)
Mutual labels:  phone
py-persian-tools
An anthology of a variety of tools for the Persian language in Python
Stars: ✭ 106 (-51.6%)
Mutual labels:  number
number-to-bengali-word
An amazing package to convert your number to bengali word representation.
Stars: ✭ 22 (-89.95%)
Mutual labels:  number
pyutilib
A collection of general Python utilities, including logging and file IO, subprocess management, plugin systems, and workflow management.
Stars: ✭ 28 (-87.21%)
Mutual labels:  codecov
Tau.jl
A Julia module providing the definition of the circle constant Tau (2π)
Stars: ✭ 33 (-84.93%)
Mutual labels:  number
node-gsm
📲 gsm modem module for node.js
Stars: ✭ 23 (-89.5%)
Mutual labels:  phone
is-primitive
Is the typeof value a javascript primitive?
Stars: ✭ 35 (-84.02%)
Mutual labels:  number
kirby-helpsection
Panel view to display help for users.
Stars: ✭ 35 (-84.02%)
Mutual labels:  maintainer-wanted
CMake-codecov
CMake module for code coverage
Stars: ✭ 82 (-62.56%)
Mutual labels:  codecov

yup-phone MIT License npm - yup-phone Tweet yup-phone validator Buy Me A Coffee

Build Status Commitizen friendly 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 about the core library here libphonenumber.
Read more about yup validator here yup

Install

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

Test

Check validation in Codesandbox

Examples

// See https://repl.it/repls/WiryCleverPatches
import * as yup from 'yup';
// const yup = require("yup");
import "yup-phone";
// require("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
})();

// See https://repl.it/repls/SwiftImpossibleCertification
import * as yup from 'yup';
// const yup = require("yup");
import "yup-phone";
// require("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
})();

// See https://repl.it/repls/PartialAlicebluePrediction
import * as yup from 'yup';
// const yup = require("yup");
import "yup-phone";
// require("yup-phone");

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

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

// See https://repl.it/repls/UniqueForsakenDownloads
import * as yup from 'yup';
// const yup = require("yup");
import "yup-phone";
// require("yup-phone");

// validate phone number strictly in the given region with custom error message
const phoneSchema = yup.string()
  .phone('IN', true, '${path} is invalid')
  .required();

try {
  phoneSchema.validateSync('+1 345 9490088');
} catch (error) {
  console.log(error.message); // → this is invalid
}

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

Module Sizes

Destination: dist/yup-phone.umd.js
Bundle Size:  544.08 KB
Minified Size:  537.41 KB
Gzipped Size:  107.04 KB 
Destination: dist/yup-phone.umd.min.js
Bundle Size:  508.65 KB
Minified Size:  506.46 KB
Gzipped Size:  105.73 KB 
Destination: dist/yup-phone.esm.js
Bundle Size:  648 B
Minified Size:  646 B
Gzipped Size:  370 B 
Destination: dist/yup-phone.cjs.js
Bundle Size:  1.35 KB
Minified Size:  1.34 KB
Gzipped Size:  662 B 

Contributing

  • Uses Rollup for bundling.
  • Uses npm for package management.
  • Files are minified using closure compiler.
  • Uses jest for testing.
  • Generates CJS, UMD, and ESM builds.
  • Use npm version [major|minor|patch] to version.
  • Use tslint and prettier for code formatting.
  • Uses semantic release for version.
  • Use npx cz to create a standard commit interactively.
$ npm run build # Build for production
$ npm test # Run tests
$ npm publish # Publish npm package (prompts for version)

License

MIT.

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].