franzin
Best Approach for Validating Thousands of Inputs in an Elixir SDK Project
Hello everyone! I hope you’re all doing well.
I’m new to the world of Elixir, and recently I decided to create an SDK (I’ll share more details soon) as a way to practice.
So far, I haven’t encountered many issues developing the core of the SDK or the Clients themselves. However, I’m uncertain about the best way to handle the inputs coming from the Clients.
Most of the inputs are maps, which will be converted into JSON and sent to the service APIs via HTTPS requests. A malformed input would result in a rejected request by the API, which I consider an unnecessary overhead. Additionally, the error returned is not always clear about what’s is wrong.
My goal is to validate these inputs — mainly checking for missing required fields — directly within the Client, to avoid burdening the API with simple validation logic.
The SDK will include several Clients, each with multiple operations, which will ultimately result in thousands of different inputs (Clients * Operations).
My question is: should I create a specific module/structure for each input, or would it be better to build a dynamic solution for map validation? What approach would you use to ensure validation is both performant and easy to maintain?
Thanks in advance for any suggestions or insights!
Most Liked
al2o3cr
Doing additional validation on every request seems like the more-likely cause of overhead since presumably you’re expecting substantially more correct requests than malformed ones.
In any case, consider JSON Schema if you need to validate a bunch of different JSON shapes; if you’re lucky, the API may already publish one.








