An extensible data validation library for Elixir with built-in validators and custom function support.
Vex is an extensible data validation library for Elixir that provides a comprehensive set of built-in validators and supports custom validation logic. It allows developers to validate data against criteria like presence, format, length, and inclusion, with support for conditional validation and error message customization. The library integrates seamlessly with Elixir structs and keyword lists, offering a flexible approach to data integrity.
Elixir developers building applications that require robust data validation, such as web APIs, form processing systems, or data transformation pipelines. It is particularly useful for teams needing customizable validation rules beyond basic type checking.
Developers choose Vex for its extensibility, built-in validator suite, and conditional validation support, which are inspired by Rails ActiveModel Validations and Clojure's Validateur. Its ability to integrate with structs and keyword lists while allowing custom validators and error renderers makes it a versatile alternative to simpler validation solutions.
Data Validation for Elixir
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Includes built-in validators for presence, absence, inclusion, format, length, number, UUID, acceptance, and confirmation, covering common validation needs as detailed in the README's 'Supported Validations' section.
Supports :if, :unless, :if_any, and :unless_any options for applying validations based on other attributes or custom functions, with examples like skipping body length if reference_url is present.
Allows adding new validators via configurable sources and overriding existing ones, demonstrated in the 'Adding and Overriding Validators' section with a custom currency validator example.
Seamlessly works with Elixir structs using Vex.Struct and keyword lists via a :_vex entry, enabling declarative validation setup without boilerplate.
Unlike Ecto's changeset validations, Vex doesn't integrate directly with database operations, requiring separate validation logic for data persistence in Phoenix applications.
Setting up custom validators and error renderers involves configuring sources and implementing protocols, which adds complexity compared to more opinionated libraries with defaults.
The library is synchronous and lacks built-in support for asynchronous validation or distributed scenarios, which might be a drawback for real-time or high-concurrency applications.