1.1.0 • Published 5 years ago
@fantasticfiasco/expect v1.1.0
@fantasticfiasco/expect
A Node.js library written in TypeScript providing argument validation.
Table of contents
Super simple to use
import * as expect from '@fantasticfiasco/expect';
function update(person) {
expect.toExist(person.name);
expect.toBeTrue(person.age >= 0, 'existential theories are not up for discussion');
// Squint your eyes and imagine your code here...
}Installation
npm install @fantasticfiasco/expect
# or
yarn add @fantasticfiasco/expectAPI
toBeTrue(condition[, errorMessage])
condition: booleanThe condition expected to be trueerrorMessage: stringThe optional error message displayed if expectation fails
Expect a condition to be true.
toBeFalse(condition[, errorMessage])
condition: booleanThe condition expected to be falseerrorMessage: stringThe optional error message displayed if expectation fails
Expect a condition to be false.
toExist<T>(value[, errorMessage])
value: TThe value expected to existerrorMessage: stringThe optional error message displayed if expectation fails
Expect a value to exist.
toNotExist<T>(value[, errorMessage])
value: TThe value expected not to existerrorMessage: stringThe optional error message displayed if expectation fails
Expect a value not to exist.
toBeAlphanumeric(value[, errorMessage])
value: stringThe value expected to be alphanumericerrorMessage: stringThe optional error message displayed if expectation fails
Expect a value to be alphanumeric.
toBeCharCodes(value, minCharCode, maxCharCode[, errorMessage])
value: stringThe value expected to have characters from a range of character codesminCharCode: numberThe expected minimum character codemaxCharCode: numberThe expected maximum character codeerrorMessage: stringThe optional error message displayed if expectation fails
Expect a value to only contain characters from a range of character codes.
Credit
Thank you JetBrains for your important initiative to support the open source community with free licenses to your products.
