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 alot
6 Replies
JavaBot
JavaBot4mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Tomasm21
Tomasm214mo ago
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.
bambyzas
bambyzasOP4mo ago
but i dont need to validate each field
Tomasm21
Tomasm214mo ago
I thought you do. Do what you want
bambyzas
bambyzasOP4mo ago
No description
JavaBot
JavaBot4mo ago
💤 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.
Want results from more Discord servers?
Add your server