I'm building a library to interact with a public API. Should I be doing validation of the data passed or leave that to the API? -
I am creating an open source library to interact with the public API. The API validates all the data sent on it and gives a non-200 status code on failure and usually returns a failure message which causes the exception of my Library Exception.
Some of my methods check the required parameters, but mostly I have decided not to validate the data before passing the API.
Will a library also validate data for an API? If so, to what extent? Should all attempts to validate this data completely or simply verify that the required criteria are not empty / empty?
There are two parts of the rule: on the input, become an approved grandmother: what does the caller take you and Be not careful about the interface conference at those places where this little difference comes; Or where you can supply appropriate defaults, on the production, follow this letter to the conference: a hardened pedal, a martinet.
So, in my opinion, the answer is yes, you should check the input of your caller and give the API the best data. can do. But it is not necessary that you should duplicate the assumption that the API is going to do anyway.
You have to use your head and think about it which makes sense.
Comments
Post a Comment