Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
http-assert-value
Advanced tools
Readme
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 9 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.