The check api

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2018-11-09 15:51:44 -02:00
parent eef6f60a9d
commit 545441e53e
2 changed files with 25 additions and 1 deletions

View File

@ -70,7 +70,9 @@ String Cloudevent.toString()
```
## `Formatter` class
## `Formatter` classes
Every formatter class must implement these methods to work properly.
```js
@ -86,6 +88,19 @@ String Formatter.toString(payload)
```
## `Spec` classes
Every Spec class must implement these methods to work properly.
```js
/*
* Check the spec constraints, throwing an error if do not pass.
*/
Spec.check()
```
# How to use
The `Cloudevent` constructor arguments.

View File

@ -19,6 +19,15 @@ function Spec_0_1(_caller){
}
}
/*
* Check the constraints.
*
* throw an error if do not pass.
*/
Spec_0_1.prototype.check = function() {
}
Spec_0_1.prototype.type = function(_type){
this.payload['eventType'] = _type;
return this;