@arcanix/validate
v1.0.0
Published
Assists in validating arguments
Downloads
20
Readme
Validate
Assists in validating arguments
Install
$ npm install @arcanix/validateUsage
Validations
Here is the list of validations:
Validation | Description --- | --- validate(value [, message]) | alias for validate.ok() validate.ok(value [, message]) | Checks if value if truthy, if not, throws a ValidationError with the specified message validate.notNull(value [, message]) | Checks if the value if not null, if null, throws a ValidationError with the specified message
Example
const validate = require('@arcanix/validate');
class SomeClass {
constructor(myFirstArgument, mySecondArgument) {
this.myFirstArgument = validate(myFirstArgument, 'expected myFirstArgument');
this.mySecondArgument = validate(mySecondArgument, 'expected mySecondArgument');
}
}