Installations
npm install yup-phone
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS, UMD
Min. Node Version
>=9
Typescript Support
No
Node Version
16.5.0
NPM Version
7.20.0
Statistics
240 Stars
377 Commits
26 Forks
6 Watching
39 Branches
5 Contributors
Updated on 12 Sept 2024
Bundle Size
597.66 kB
Minified
126.98 kB
Minified + Gzipped
Languages
TypeScript (50.48%)
JavaScript (49.52%)
Total Downloads
Cumulative downloads
Total Downloads
4,410,812
Last day
2.3%
4,161
Compared to previous day
Last week
2%
20,812
Compared to previous week
Last month
7.7%
88,942
Compared to previous month
Last year
-38.6%
1,125,485
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
39
yup-phone
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
1# npm install --save yup-phone 2$ npm add yup-phone
Test
Check validation in Codesandbox
Examples
1// See https://repl.it/repls/WiryCleverPatches 2import * as yup from 'yup'; 3// const yup = require("yup"); 4import "yup-phone"; 5// require("yup-phone"); 6 7// validate any phone number (defaults to India for country) 8const phoneSchema = yup.string() 9 .phone() 10 .required(); 11 12(async () => { 13 console.log(await phoneSchema.isValid("9876543210")); // → true 14})();
1// See https://repl.it/repls/SwiftImpossibleCertification 2import * as yup from 'yup'; 3// const yup = require("yup"); 4import "yup-phone"; 5// require("yup-phone"); 6 7// validate phone number loosely in the given region 8const phoneSchema = yup.string() 9 .phone("IN") 10 .required(); 11 12(async () => { 13 console.log(await phoneSchema.isValid('+919876543210')); // → true 14})();
1// See https://repl.it/repls/PartialAlicebluePrediction 2import * as yup from 'yup'; 3// const yup = require("yup"); 4import "yup-phone"; 5// require("yup-phone"); 6 7// validate phone number strictly in the given region 8const phoneSchema = yup.string() 9 .phone("IN", true) 10 .required(); 11 12console.log(phoneSchema.isValidSync("+919876543210")); // → true
1// See https://repl.it/repls/UniqueForsakenDownloads 2import * as yup from 'yup'; 3// const yup = require("yup"); 4import "yup-phone"; 5// require("yup-phone"); 6 7// validate phone number strictly in the given region with custom error message 8const phoneSchema = yup.string() 9 .phone('IN', true, '${path} is invalid') 10 .required(); 11 12try { 13 phoneSchema.validateSync('+1 345 9490088'); 14} catch (error) { 15 console.log(error.message); // → this is invalid 16}
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.
1$ npm run build # Build for production 2$ npm test # Run tests 3$ npm publish # Publish npm package (prompts for version)
License
MIT.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Info: no jobLevel write permissions found
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 19 are checked with a SAST tool
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/abhisekp/yup-phone/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/abhisekp/yup-phone/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/abhisekp/yup-phone/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/abhisekp/yup-phone/codeql-analysis.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
28 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-hj9c-8jmm-8c52
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.2
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More