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

bedrock-validation

Package Overview
Dependencies
Maintainers
5
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bedrock-validation - npm Package Compare versions

Comparing version

to
5.2.1

6

CHANGELOG.md
# bedrock-validation ChangeLog
## 5.2.1 - 2021-12-14
### Fixed
- Fix `api.validate` to throw error if schema does not exist instead of
returning middleware that raises the error.
## 5.2.0 - 2021-07-23

@@ -4,0 +10,0 @@

29

lib/index.js

@@ -121,13 +121,15 @@ /*!

// schema does not exist
if(notFound) {
const err = new BedrockError(
'Could not validate data; unknown schema name (' + notFound + ').',
'UnknownSchema', {schema: notFound});
if(typeof callback === 'function') {
return callback(err);
}
throw err;
}
// do immediate validation if data is present
if(arguments.length > 1) {
if(notFound) {
const err = new BedrockError(
'Could not validate data; unknown schema name (' + notFound + ').',
'UnknownSchema', {schema: notFound});
if(typeof callback === 'function') {
return callback(err);
}
throw err;
}
// use schema.body (assume 3 parameter is called w/string)

@@ -137,11 +139,2 @@ return api.validateInstance(data, schemas.body, callback);

// schema does not exist, return middle that raises error
if(notFound) {
return (req, res, next) => {
next(new BedrockError(
'Could not validate request; unknown schema name (' + notFound + ').',
'UnknownSchema', {schema: notFound}));
};
}
// return validation middleware

@@ -148,0 +141,0 @@ // both `query` and `body` may need to be validated

{
"name": "bedrock-validation",
"version": "5.2.0",
"version": "5.2.1",
"description": "Bedrock validation",

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

@@ -71,2 +71,17 @@ /*

});
it('should throw an UnknownSchema error when schema does not exist',
function() {
let result;
let err;
try {
result = validation.validate('test');
} catch(e) {
err = e;
}
should.exist(err);
should.not.exist(result);
err.name.should.equal('UnknownSchema');
});
});

@@ -73,0 +88,0 @@