How to add validation on required schema field #106
Unanswered
elmalakomar
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi @elmalakomar! How do you do the validation with the library? I think you could use directly the I think it's an interesting use case, which could be also integrated optionally inside gswagger (so, the validation of the request which if not as desired returns 400). What do you think about? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm having problems trying to add a validation on a json schema header. The desired behavior is to have an error if in the Headers of he request it's missing the field "Authorization" or the field value is empty.
I tried two approaches but I seems the validation is not doing the expected behavior:
1)
with AuthorizationHeader defined like this:
How can I achieve the expected behavior? Thanks!
Note: The
validate:"required"
annotation comes from this library: https://pkg.go.dev/github.com/go-playground/validator/v10@v10.11.2I used it to validate a body request field and it works.
Beta Was this translation helpful? Give feedback.
All reactions