Scrutinex

CI

Declarative validation for tabular data in Elixir.

Define schemas with an Ecto-style DSL, then validate lists of maps from CSVs, APIs, or any other source — with type coercion, built-in checks, regex column matching, and cross-column validation.

Installation

def deps do
  [{:scrutinex, "~> 0.1.0"}]
end

Example

defmodule OrderSchema do
  use Scrutinex.Schema, strict: true

  column "id",       :integer, coerce: true
  column "customer", :string,  checks: [length: [min: 1]]
  column "amount",   :float,   coerce: true, checks: [number: [greater_than: 0]]
  column "status",   :string,  checks: [inclusion: ["pending", "shipped", "delivered"]]

  check :amount_valid do
    fn row -> row["amount"] > 0 or row["status"] == "pending" end
  end
end

result = Scrutinex.validate(data, OrderSchema)
result.valid?  #=> true
result.data    #=> [%{"id" => 1, "amount" => 99.99, ...}, ...]
result.errors  #=> []

Features

Formatter

Add to your .formatter.exs for parens-free DSL:

[
  import_deps: [:scrutinex]
]

Documentation

Full documentation is available on HexDocs.

License

MIT — see LICENSE.