Domo makes your structure types work for data conformance validation. And it enables automatic range checking for field types at run-time.
That is independent of database or any custom notation, only standard Elixir type definitions and pure functions.
Domo adds a
new/1 constructor function to the structure module that builds an instance only if all fields conform to the struct’s
t() type and all specified precondition functions for filed types return true.
That makes it possible to validate model types in microservice setups between depending applications by sharing a common model among codebases. That can be structs, user-defined types, and appropriate precondition functions.
Domo main features are:
ensure_type_ok/1functions for a struct using Domo
- support for boolean precondition function for the user-defined type or the whole struct’s
t()type to specify range checks
- automatic generation of conformance validation function from the struct’s
t()type at compile-time
- validation of data conformance to the struct type when constructing an instance both at compile and run-times
- dependency tracking to recompile modules when affecting type definition changes
More information here: