@@ -107,13 +107,12 @@ export class CloudEvent implements CloudEventV1, CloudEventV03 {
107
107
// value is the value on the right side of the equal sign
108
108
set : function ( obj , prop : string , value ) {
109
109
// Make a copy of the incoming Object, need to have all it's properties and such
110
- const updateObj = Object . create ( obj ) ;
110
+ const updateObj : CloudEvent = Object . create ( obj ) ;
111
111
// Update it with the new value
112
112
updateObj [ prop ] = value ;
113
113
114
114
// Validate the object
115
- obj . validate ( updateObj ) ;
116
-
115
+ updateObj . validate ( ) ;
117
116
// If we succeed, then Update the real object
118
117
// Set the new value normally
119
118
obj [ prop ] = value ;
@@ -172,16 +171,12 @@ export class CloudEvent implements CloudEventV1, CloudEventV03 {
172
171
* @throws if the CloudEvent does not conform to the schema
173
172
* @return {boolean } true if this event is valid
174
173
*/
175
- public validate ( cloudEvent ?: CloudEvent ) : boolean {
176
- if ( ! cloudEvent ) {
177
- cloudEvent = this ;
178
- }
179
-
174
+ public validate ( ) : boolean {
180
175
try {
181
- if ( cloudEvent . specversion === Version . V1 ) {
182
- return validateV1 ( cloudEvent ) ;
183
- } else if ( cloudEvent . specversion === Version . V03 ) {
184
- return validateV03 ( cloudEvent ) ;
176
+ if ( this . specversion === Version . V1 ) {
177
+ return validateV1 ( this ) ;
178
+ } else if ( this . specversion === Version . V03 ) {
179
+ return validateV03 ( this ) ;
185
180
}
186
181
throw new ValidationError ( "invalid payload" ) ;
187
182
} catch ( e ) {
0 commit comments