ExJoi – Declarative Validation for Elixir

ExJoi v0.9.0 - Async Validation & Parallel Processing

Just released ExJoi v0.9.0 with async validation support! Now you can validate with external services, database lookups, and long-running computations—all running in parallel using Task.async_stream.

What’s New

  • Async validators with ExJoi.async/3 for external service checks

  • Parallel processing - multiple async fields validate simultaneously

  • Timeout control - configurable timeouts per rule or globally

  • Array element validation - validate array items in parallel

Quick Example

schema = ExJoi.schema(%{
  username: ExJoi.async(
    ExJoi.string(required: true, min: 3),
    fn value, _ctx ->
      Task.async(fn ->
        if UsernameService.available?(value) do
          {:ok, value}
        else
          {:error, [%{code: :username_taken, message: "username is already taken"}]}
        end
      end)
    end,
    timeout: 3000
  )
})

# Multiple async fields run in parallel automatically
ExJoi.validate(data, schema, max_concurrency: 5)


Next Plan: Meta Programming & Schema Compiler

The next version of ExJoi will focus on high-performance validation:

  • Pre-compiled schemas for faster runtime execution

  • Macro DSL for declarative and efficient schema definitions

  • Pattern-matching based validation for speed

  • Schema caching with ETS

  • Additional performance optimizations

This will make ExJoi faster and more scalable, especially for large or complex validation scenarios.

Call for Collaborators

If you’re interested in Elixir, meta programming, or performance optimizations, I’d love your help building this next phase! Contributions, ideas, and experiments are very welcome.

Resources

Check out the full documentation for real-world examples, error handling, and best practices!

2 Likes