Cogswell Pub-Sub Dialect
This package is a collection of JavaScript object validators to validate cogswell pub-sub request/response objects. This package uses the Joi library for validation.
Pub/Sub JSON Dialect
The dialect definition can be found at the Pub/Sub Dialect page.
Usage
const validators = ; const exampleObject = sequence: 12345 code: 404 message: 'Not Found' details: 'There are no subscribers to the specified channel, so the message could not be delivered.' //without callbackconst result = validators;result == err: null value: exampleObject; //true //with callbackconst result = validators; //the validate function is a direct alias to Joi's validate therefore you can do this (or the callback version):const result = Joi;result == err: null value: exampleObject; //true
Validators
Use the following validators to validate their respective objects
-
general
- catchAllError
- invalidFormatError
-
subscribe
- directive
- success
- incorrectPermissionsError
-
unsubscribe
- directive
- success
- incorrectPermissionsError
- notFoundError
-
publish
- directive
- incorrectPermissionsError
- noSubscriptionsError
-
message
Testing
To run the unit tests, run the following command
npm test