-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Customizing Cloudevents validation
Signed-off-by: vbhat6 <[email protected]>
- Loading branch information
vbhat6
committed
Feb 15, 2024
1 parent
62c55e7
commit 8c66b1b
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
core/src/test/java/io/cloudevents/core/test/CloudEventCustomValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.cloudevents.core.test; | ||
|
||
import io.cloudevents.CloudEvent; | ||
import io.cloudevents.core.validator.CloudEventValidator; | ||
|
||
public class CloudEventCustomValidator implements CloudEventValidator { | ||
|
||
@Override | ||
public void validate(CloudEvent cloudEvent) { | ||
String namespace = null; | ||
if ((namespace = (String) cloudEvent.getExtension("namespace")) != null && | ||
!namespace.equals("sales")){ | ||
throw new IllegalStateException("Expecting sales in namespace extension"); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
core/src/test/resources/META-INF/services/io.cloudevents.core.validator.CloudEventValidator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.cloudevents.core.test.CloudEventCustomValidator |