
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
http-assert-value
Advanced tools
npm install http-assert-value --save
const assert = require('http-assert-value');
// Common assert interface
assert(+0 === -0, 'Zeros are not equal', 500, 'ZNE', {
leftOperand: +0,
reghtOperand: -0,
operation: '==='
}); // Ok
// Assert typed values
assert.identity('green-mile'); // Ok
assert.float('3.14'); // Ok
assert.positiveInt('12'); // Ok
assert.text('The Green Mile'); // Ok
// Assert by JSON schema
// @see: http://json-schema.org/
assert.bySchema('1', { type: 'integer' }); // Ok
// All methods have duplicates with `try...`
assert.text(undefined); // Error
assert.tryText(undefined); // Ok
try {
assert.text('DROP DATABASE BOOKS;');
} catch (error) {
error.message; // 'Text is invalid'
error.statusCode; // 400
error.options; // { value: 'DROP DATABASE BOOKS;', internalCode: '400_TVI' }
}
Assert value with http-specific error data
Any
- asserting valueString
- error textNumber
- error http-codeString
- three-letter error codeObject
- error additional informationAssert slug or unique identity value
String|Array<String>
- asserting valueString
- name of the parameter containing valueAssert float value
String|Array<String>
- asserting valueString
- name of the parameter containing valueAssert positive integer value
String|Array<String>
- asserting valueString
- name of the parameter containing valueAssert text, like search request
String|Array<String>
- asserting valueString
- name of the parameter containing valueAssert object by schema
Any|Array<Any>
- asserting valueObject
- json-schemaObject
- ajv constructor optionsAssert value, that it is in array
Any
- asserting valueArray
- array which contains expected valuesFunction
- function which compare values from array with asserting
value. By default used comparator to compare primitive ((lhs, rhs) => lhs === rhs
)Alias for assert.positiveInt
Assert that value length is less than passed maxLength
Any
- asserting valueNumber
- max allowed length of a stringString
- name of the parameter containing valueEvery method has try-version method, which has same interface and assert value, when value is passed:
FAQs
assert values with status codes
The npm package http-assert-value receives a total of 3 weekly downloads. As such, http-assert-value popularity was classified as not popular.
We found that http-assert-value demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.