I’ve implemented a validation library that’s basically a copy of Ecto’s Changeset validations. Rather than working on schemas, these validations work on plain maps and structs. It also doesn’t (currently) implement any sort of coercion or casting.
I’m curious if anyone else would find this useful. If so, I’d be happy to open source what I’ve got.
Before you answer my question I’m sure some of you these two questions:
- Why not just use Ecto?
For the purpose of my project, I didn’t need Ecto. Importing a database/schema library when I don’t need databases or schemas seemed unnecessary to me. Even when I am using Ecto sometimes it doesn’t make sense to convert my structs to schemas for no other purpose than validation. I just want to pass in a map or struct and get some validations back.
Yes, I know you can use Ecto on plain maps if you pass in types as a tuple instead of a schema but even that seems unnecessary in most non-Ecto circumstances.
- Why not use Vex?
This was originally the route I went. After getting knee deep into implementation I was finding that it’s ActiveRecord inspiration created unneeded complexity. One of the things I love about Ecto’s validations is that they’re just functions. No need to add a module with callbacks to implement new validations.
This is my rationale. If the community would find this useful I’d be happy to contribute it. Otherwise, I’ll just keep it to myself and not spend the time on documentation/support.