Skip to content

Commit ca51238

Browse files
committed
Did validationg
1 parent d8d3380 commit ca51238

File tree

1 file changed

+14
-0
lines changed
  • examples/powertools-examples-validation

1 file changed

+14
-0
lines changed

examples/powertools-examples-validation/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@
33
This project contains an example of Lambda function using the validation module of Powertools for AWS Lambda (Java).
44
For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/validation/).
55

6+
The handler [InboundValidation](src/main/java/org/demo/validation/InboundValidation.java) validates incoming HTTP requests
7+
received from the API gateway against [schema.json](src/main/resources/schema.json).
8+
69
## Deploy the sample application
710

811
This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting
912
started with SAM in [the examples directory](../README.md)
1013

1114
## Test the application
1215

16+
To test the validation, we can POST a JSON object shaped like our schema:
17+
```bash
18+
curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/hello/ -H "Content-Type: application/json" -d '{"address": "https://checkip.amazonaws.com"}'
19+
```
20+
21+
If we break the schema - for instance, by removing one of the compulsory fields,
22+
we will get an error back from our API and will see a `ValidationException` in the logs:
23+
24+
```bash
25+
sam logs --tail --stack-name $MY_STACK
26+
```

0 commit comments

Comments
 (0)