0

hey I have a function in lambda with spring cloud functions that takes a dataobject as a input param say (InputObj). The lambda is triggered via an api gateway. The problem is if I leave out some properties of the InputObj and send a request. I get a default value for those missing properties.

What I would need is something like a 400 bad request error to be thrown unless the user provide all properties of the InputObj.

how can i go about doing it.

1 Answers1

0

I say the simplest way to do that is to:

  1. Not have default values. What's the point of having them if you are saying they are not valid.
  2. Have the getter for the property to throw an exception if such property was not set. This way it will fail during serialization resulting in bad HTTP response
Oleg Zhurakousky
  • 5,820
  • 16
  • 17
  • tnx but i dont set any default values for the properties. Let s say an int property of age exists. The deserialization sets a value of 0 to it. I am interested more in a spring mvc like behaviour where I get a bad request if I dont set a property of a dataobject during deserialization. – vignesh suresh Oct 10 '22 at 13:47
  • Have you tried the suggestion i have made? Remember, we're not trying to mimic MVC, rather provide a light way model of realizing Java function as AWS lambda. Sure additional features may be included over time, but at this tome no one have requested something like this. And the solution I am proposing is fairly simple and independent of any web framework making your function portable which is another point of s-c-function. – Oleg Zhurakousky Oct 10 '22 at 14:48