Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

joi-phone-number

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-phone-number - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

10

lib/__tests__/joiPhoneNumber.test.js

@@ -73,2 +73,12 @@ 'use strict';

it('validates and formats without a country', () => {
const joi = Joi.extend(JoiPhoneNumber);
const schema = joi.string().phoneNumber({
format: 'e164'
});
expect(schema.validate('32494322456').error).toBeInstanceOf(Error);
expect(schema.validate('+32494322456').error).toBeNull();
});
it('should take multiple countries', () => {

@@ -75,0 +85,0 @@ const joi = Joi.extend(JoiPhoneNumber);

12

lib/index.js

@@ -44,4 +44,12 @@ 'use strict';

} catch (err) {
const knownErrors = ['Invalid country calling code', 'The string supplied did not seem to be a phone number'];
// We ignore the next line for line coverage since we should always hit it but if we have a regression in our code we still want to surface that instead of just returning the default error
/* istanbul ignore next */
if (knownErrors.includes(err.message)) {
// Generate an error, state and options need to be passed
return this.createError('string.phonenumber', {value}, state, options);
return this.createError('string.phonenumber', {value}, state, options);
}
/* istanbul ignore next */
throw err;
}

@@ -60,3 +68,3 @@ }

*/
internals.parse = (value, [...countries]) => {
internals.parse = (value, [...countries] = []) => {
const country = countries.shift();

@@ -63,0 +71,0 @@ try {

2

package.json
{
"name": "joi-phone-number",
"version": "3.0.0",
"version": "3.0.1",
"description": "Phone number validation rule for Joi",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/Salesflare/joi-phone-number",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc