Hey,
I have used a bunch of schema libraries in Elixir and didn’t find the one satisfies all my needs. At some point, I kinda miss Python for having Pydantic. So recently I started to make one for myself.
Elixact
Elixact is a schema definition and validation library, inspired by Python’s Pydantic.
Features
Intuitive Schema DSL - Similar to
Ecto.Schema
syntaxStrong Type Validation - Comprehensive validation for basic and complex types
JSON Schema Support - Automatic generation of JSON Schema from your Elixir schemas
Custom Types - Easily define reusable custom types
Nested Schemas - Support for deeply nested data structures
Field Constraints - Rich set of built-in constraints
Structured Errors - Clear and actionable error messages
See the doc for more details: elixact v0.1.1 — Documentation
Github: GitHub - LiboShen/elixact: schema definition and validation library for Elixir
Hex: elixact | Hex
Credits / Prior Arts
As I mentioned above, I have tried many libraries to give me strong data validations. I took inspirations from all of them:
Ecto is the obvious choice when you need simple a schema.
Typestruct is a lightweight improvement of the builtin struct
.
Drops is the closest of what I need. But I failed to make it work with nested or complex schemas.
I’m using it for my several projects now. Let me know if you find this is useful. I’m open for collaboration to make it better. Thanks.