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

freeman-check

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freeman-check - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

2

package.json
{
"name": "freeman-check",
"version": "3.0.4",
"version": "3.0.5",
"description": "Easy type and format checking on JavaScript objects",

@@ -5,0 +5,0 @@ "scripts": {

@@ -74,2 +74,6 @@ "use strict";

break;
case 'enum':
subject = error.property.replace('instance.', '');
problem = 'needs to be one of ' + error.argument.map(s => `"${s}"`).join(', ');
break;
}

@@ -76,0 +80,0 @@ // concatenate all validation errors.

@@ -15,2 +15,3 @@ "use strict";

website: { type: 'string', format: 'uri' },
status: { type: 'string', enum: ['active', 'inactive', 'pending'] },
},

@@ -91,3 +92,26 @@ required: ['name', 'email', 'favourite_films'],

});
describe('Enum check', () => {
it('should throw an error if object has incorrect enum value', () => {
const object = {
name,
email,
favourite_films,
status: 'unknown', // Incorrect enum value
};
(0, chai_1.expect)(() => check(schema).test(object)).to.throw(CheckError_1.CheckError, '`status` needs to be one of "active", "inactive", "pending".');
});
});
describe('Multiple errors', () => {
it('should be able to return multiple errors joined together', () => {
const object = {
name,
email: 'invalid-email',
favourite_films: 'Transformers',
website: 'invalid-website',
status: 'unknown', // Incorrect enum value
};
(0, chai_1.expect)(() => check(schema).test(object)).to.throw(CheckError_1.CheckError, '`email` needs to be formatted as `email`. `favourite_films` needs to be an `array`. `website` needs to be formatted as `uri`. `status` needs to be one of "active", "inactive", "pending".');
});
});
});
});
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