Skip to main content

isCloudEvent

@webda/cloudevents


Function: isCloudEvent()

isCloudEvent(obj, strict?): boolean

Defined in: cloudevent.ts:36

Check if an object conforms to the CloudEvents specification.

In loose mode (default), verifies that the required attributes (specversion, type, source, id) exist and are strings.

In strict mode, additionally validates:

  • specversion equals "1.0"
  • Required attributes are non-empty strings
  • Optional attributes (time, datacontenttype, dataschema, subject), when present, have valid values

Parameters​

obj​

unknown

the object to check

strict?​

boolean = false

enable strict validation (default: false)

Returns​

boolean

true if the object matches the CloudEvents spec