#how to validate three similar objects that come into my controller?

8 messages · Page 1 of 1 (latest)

winter scaffold
#

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

lunar streamBOT
#

This post has been reserved for your question.

Hey @winter scaffold! 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.

pearl forge
#

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.

winter scaffold
pearl forge
#

I thought you do.

#

Do what you want

winter scaffold