5.1.1 • Published 3 years ago
joi-phone-number v5.1.1
joi-phone-number
Phone number validation rule for Joi
What
Allows you to do Joi.string().phoneNumber()
.
Uses https://github.com/ruimarinho/google-libphonenumber for validation.
Which is a compiled version of the Google library https://github.com/googlei18n/libphonenumber.
How
const myCustomJoi = Joi.extend(require('joi-phone-number'));
myCustomJoi.string().phoneNumber().validate('+32494567324');
// The phone number can be transformed to a custom format
// Note that this follows Joi's `convert` option
myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'e164' }).validate('494322456'); // '+32494322456'
myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'international' }).validate('494322456'); // '+32 494 32 24 56'
myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'national' }).validate('494322456'); // '0494 32 24 56'
myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'rfc3966' }).validate('494322456'); // 'tel:+32-494-32-24-56'
myCustomJoi.string().phoneNumber({ defaultCountry: 'US', strict: true }).validate('7777777777'); // validation error
myCustomJoi.string().phoneNumber({ defaultCountry: 'US'}).validate('7777777777'); // 7777777777
5.1.1
3 years ago
5.1.0
3 years ago
5.0.1
4 years ago
5.0.0
4 years ago
4.1.2
5 years ago
4.1.1
5 years ago
4.1.0
5 years ago
4.0.1
5 years ago
4.0.0
5 years ago
3.1.1
5 years ago
3.1.0
5 years ago
3.0.3
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
3.0.0
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.15
6 years ago
2.0.14
6 years ago
2.0.13
6 years ago
2.0.12
7 years ago
2.0.11
7 years ago
2.0.10
7 years ago
2.0.9
7 years ago
2.0.8
7 years ago
2.0.7
7 years ago
2.0.6
7 years ago
2.0.5
7 years ago
2.0.4
7 years ago
2.0.3
7 years ago
2.0.2
7 years ago
2.0.1
7 years ago
2.0.0
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago