1.3.2 • Published 2 years ago
yup-phone v1.3.2
yup-phone
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.
1.3.2
2 years ago
1.3.1
2 years ago
1.2.19
3 years ago
1.2.18
3 years ago
1.2.17
3 years ago
1.2.16
3 years ago
1.2.15
3 years ago
1.2.14
3 years ago
1.2.13
4 years ago
1.2.12
4 years ago
1.2.11
4 years ago
1.2.10
4 years ago
1.2.9
4 years ago
1.2.8
4 years ago
1.2.7
4 years ago
1.2.6
4 years ago
1.2.5
4 years ago
1.2.4
4 years ago
1.2.3
4 years ago
1.2.2
4 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.2
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago