how to validate three similar objects that come into my controller?
hey guys. i have an api with 3 endpoints. each endpoint reveices the same DTO object. but the values vary.
1st endpoint receives object with these fields: transactionId, clientId, amount, signature
2nd endpoint receives object with these fields: transactionId, amount, signature
3rd endpoint: transactionId, signature
signature is generated before calling the first endpoint. its just transactionId, clientId and amount concatenated together. and then the same signature is used in the 2nd and 3rd endpoints/requests.
i want to have a method to somehow validate
signature
field in requests. i dont know how can i have a generic/universal method that can be used for all three objects. would it mean that i need to have three different methods? any ideas? thanks alot6 Replies
⌛
This post has been reserved for your question.
Hey @bambyzas! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
You can have 1 method that checks all DTO fields. It checks whether each field is not null or not empty or blank and if it is not the case then each field can be appropriately validated.
but i dont need to validate each field
I thought you do.
Do what you want
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.