Skip to content

Commit 1f2841d

Browse files
committed
The check api
1 parent 32db98c commit 1f2841d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ String Cloudevent.toString()
7070

7171
```
7272

73-
## `Formatter` class
73+
## `Formatter` classes
74+
75+
Every formatter class must implement these methods to work properly.
7476

7577
```js
7678

@@ -86,6 +88,19 @@ String Formatter.toString(payload)
8688

8789
```
8890

91+
## `Spec` classes
92+
93+
Every Spec class must implement these methods to work properly.
94+
95+
```js
96+
97+
/*
98+
* Check the spec constraints, throwing an error if do not pass.
99+
*/
100+
Spec.check()
101+
102+
```
103+
89104
# How to use
90105

91106
The `Cloudevent` constructor arguments.

lib/specs/spec_0_1.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ function Spec_0_1(_caller){
1919
}
2020
}
2121

22+
/*
23+
* Check the constraints.
24+
*
25+
* throw an error if do not pass.
26+
*/
27+
Spec_0_1.prototype.check = function() {
28+
29+
}
30+
2231
Spec_0_1.prototype.type = function(_type){
2332
this.payload['eventType'] = _type;
2433
return this;

0 commit comments

Comments
 (0)