Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Provides a collection of runtime assertion tools for checking strict equality, type, and range of a set of values.
Provides a collection of assertion tools for checking strict equality, type, and range of a set of values.
This project aims to simplify runtime value checking for safety-critical applications.
Migration Notice 0.2.1 --> 1.0.0:
export declare function cert(...values: any): Certifier
export declare function check(...values: any): Checker
export {
Certifier,
Checker,
RangeArgumentError,
RangeAssertionError,
TypeArgumentError,
TypeAssertionError,
ValueArgumentError,
ValueAssertionError
};
export default cert;
Update 1.0.0:
yarn add cert-is
cd /path/to/node_modules/cert-is
yarn install -dev
yarn test
Please raise an issue if you find any. Pull requests are welcome!
Ƭ AnyConstructorFunction: object
Defined in src/certifier.ts:16
Any function that uses new to construct an object.
▸ cert(...values
: any): Certifier
Defined in src/index.ts:59
Constructs a Certifier instance given a set of values. All values must pass the supplied tests.
func
cert
example
const certifier = cert('foo', 'bar')
certifier.is('foo') // undefined
certifier.is('bar') // undefined
certifier.is('qux') // THROWS ValueAssertionError
example
cert('foo').is('foo') // returns Certifier instance
cert('foo').is('bar') // THROWS ValueAssertionError
cert('foo').is('foo', 'bar') // returns Certifier instance
cert('foo').isNot('foo') // THROWS ValueAssertionError
cert('foo').isType('string') // returns Certifier instance
cert('foo').isType('number') // THROWS TypeAssertionError
cert('foo').isType('string', 'number') // returns Certifier instance
cert(new Map()).isType(Map) // returns Certifier instance
cert(new Map()).isType(Object) // returns Certifier instance
cert(new Map()).isType(Set) // THROWS TypeAssertionError
cert(new Map()).isType(Map, Set) // returns Certifier instance
cert(15).isGT(2) // returns Certifier instance
cert(15).isGT(2).isLT(17) // returns Certifier instance
cert(18).isGT(17).isLT(2) // THROWS RangeAssertionError
cert(15).isGT(15) // THROWS RangeAssertionError
cert(15).isGTE(15) // returns Certifier instance
cert(15, 23).isGTE(15) // returns Certifier instance
cert(15, 23).isGTE('foo') // THROWS TypeArgumentError
Parameters:
Name | Type | Description |
---|---|---|
...values | any | Values to construct Certifier with. |
Returns: Certifier
Certifier instance.
▸ check(...values
: any): Checker
Defined in src/index.ts:80
Constructs a Checker instance given a set of values. All values must pass the supplied tests.
func
check
example
check('foo').is('foo') // returns true
check('foo').is('bar') // returns Checker instance
check('foo').isType('string') // returns true
check('foo').isType('bar') // THROWS TypeArgumentError
check('foo').isGT('') // THROWS TypeArgumentError
Parameters:
Name | Type | Description |
---|---|---|
...values | any | Values to construct Checker with. |
Returns: Checker
Checker instance.
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
Provides a collection of runtime assertion tools for checking strict equality, type, and range of a set of values.
The npm package cert-is receives a total of 11 weekly downloads. As such, cert-is popularity was classified as not popular.
We found that cert-is 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.