3 ms·
As soon as you receive an untyped input, make it conform to a typed data structure, and throw some kind of error if you can't. That way you catch any issues in
by alexatkeplar 14y ago
As soon as you receive an untyped input, make it conform to a typed data structure, and throw some kind of error if you can't. That way you catch any issues in your input data long before it bubbles through your app and causes a problem which is super-hard to track down.
See e.g. DictShield for Python (https://github.com/j2labs/dictshield https://github.com/j2labs/dictshield), Jackson for JVM (http://jackson.codehaus.org/ http://jackson.codehaus.org/), Swiz for node.js (https://github.com/racker/node-swiz https://github.com/racker/node-swiz)...