New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixul/joi-country

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixul/joi-country - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

22

lib/index.js

@@ -9,16 +9,24 @@ 'use strict';

base: joi.string(),
type: 'country',
type: 'string',
messages: {
'country.base': '{{#label}} needs to be a valid ISO 3166-1 alpha-2 country code'
'country.invalid': '{{#label}} needs to be a valid ISO 3166-1 alpha-2 country code'
},
validate: (value, helpers) => {
rules: {
country: {
method(options) {
if (Countries.isValid(value)) {
return this.$_addRule('country');
},
validate(value, helpers) {
return { value: value.toUpperCase() };
if (Countries.isValid(value)) {
return value.toUpperCase();
}
return helpers.error('country.invalid');
}
}
return { value, errors: helpers.error('country.base') };
}
};
};
{
"name": "@pixul/joi-country",
"version": "0.0.1",
"version": "1.0.0",
"description": "ISO Country extension for Joi",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -20,3 +20,3 @@ 'use strict';

const customJoi = Joi.extend(JoiCountry);
expect(customJoi._types.has('country')).to.equal(true);
expect(customJoi.string().country).to.be.a.function();
}

@@ -32,3 +32,3 @@ catch (err) {

const customJoi = Joi.extend(JoiCountry);
const schema = customJoi.country();
const schema = customJoi.string().country();
const result = await schema.validateAsync('GB');

@@ -41,3 +41,3 @@ expect(result).to.equal('GB');

const customJoi = Joi.extend(JoiCountry);
const schema = customJoi.country();
const schema = customJoi.string().country();
const result = await schema.validateAsync('de');

@@ -50,3 +50,3 @@ expect(result).to.equal('DE');

const customJoi = Joi.extend(JoiCountry);
const schema = customJoi.country();
const schema = customJoi.string().country();
await expect(schema.validateAsync('Denmark')).to.reject(ValidationError, '"value" needs to be a valid ISO 3166-1 alpha-2 country code');

@@ -58,4 +58,4 @@ });

const customJoi = Joi.extend(JoiCountry);
const schema = customJoi.country();
const schema = customJoi.string().country();
await expect(schema.validateAsync(123)).to.reject(ValidationError, '"value" must be a string');
});
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