You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/validation.md
+28-23Lines changed: 28 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ This utility provides JSON Schema validation for payloads held within events and
8
8
**Key features**
9
9
10
10
* Validate incoming events and responses
11
-
* Built-in validation for most common events (API Gateway, SNS, SQS, ...)
11
+
* Built-in validation for most common events (API Gateway, SNS, SQS, ...) and support for partial batch failures (SQS, Kinesis)
12
12
* JMESPath support validate only a sub part of the event
13
13
14
14
## Install
@@ -100,10 +100,15 @@ The validator is configured to enable format assertions by default even for 2019
100
100
`@Validation` annotation is used to validate either inbound events or functions' response.
101
101
102
102
It will fail fast if an event or response doesn't conform with given JSON Schema. For most type of events a `ValidationException` will be thrown.
103
+
103
104
For API gateway events associated with REST APIs and HTTP APIs - `APIGatewayProxyRequestEvent` and `APIGatewayV2HTTPEvent` - the `@Validation`
104
105
annotation will build and return a custom 400 / "Bad Request" response, with a body containing the validation errors. This saves you from having
105
106
to catch the validation exception and map it back to a meaningful user error yourself.
106
107
108
+
For SQS and Kinesis events - `SQSEvent` and `KinesisEvent`- the `@Validation` annotation will add the invalid messages
109
+
to the batch item failures list in the response, respectively `SQSBatchResponse` and `StreamsEventResponse`
110
+
and removed from the event so that you do not process them within the handler.
111
+
107
112
While it is easier to specify a json schema file in the classpath (using the notation `"classpath:/path/to/schema.json"`), you can also provide a JSON String containing the schema.
108
113
109
114
=== "MyFunctionHandler.java"
@@ -160,31 +165,31 @@ For the following events and responses, the Validator will automatically perform
0 commit comments