1.0.0 • Published 4 years ago

@arcanix/validate v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

Validate

Assists in validating arguments

Install

$ npm install @arcanix/validate

Usage

Validations

Here is the list of validations:

ValidationDescription
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');  
  }

}