Is there a way to do Request Validation with httpA...
# help
d
Is there a way to do Request Validation with httpApi? If not the way that RestApi does it, is there a better way to handle validation with httpApi?
a
I think the answer is no. Request validation within API Gateway is one of the things that the higher price and latency of REST API buys you. Even before HTTP APIs though, I preferred to do validation within my Lambda (assuming that's your API target). It's just simpler.
s
request validation within Lambda does seem to be the preferred pattern (and probably required if you're using HTTP APIs that currently lacks this feature). I could imagine API GWs native request validation is more useful when you're not integrating with Lambda directly (e.g. going straight to DynamoDB, SQS, etc)
d
Anyone know of a good go-to JS field validation lib?
m
I do request validation in RestAPI and I think it’s a great feature. I can’t use HttpAPI anyway because it lacks xray and waf support.
a
REST API has some great features, for sure. Just don't use (use HTTP APIs) it if you aren't taking advantage of those features.
l
@Dan Van Brunt I use
ow
for specific fields in the request but have seen a sst example for using whole schema validation with
Middy
[Edit] Here's the link: https://serverless-stack.com/examples/how-to-use-middy-to-validate-your-serverless-api-requests.html