View Source Goal.Syntax (goal v0.1.0)

Goal.Syntax provides the defschema macro to define schemas.

usage

Usage

import Goal.Syntax

Link to this section Summary

Functions

A macro for defining validation schemas.

Link to this section Functions

Link to this macro

defschema(list)

View Source (macro)
@spec defschema([{:do, {:__block__, any(), any()}}]) :: any()

A macro for defining validation schemas.

import Goal.Syntax

defp schema do
  defschema do
    required :id, :string, format: :uuid
    required :name, :string
    optional :age, :integer, min: 0, max: 120
    optional :gender, :enum, values: ["female", "male", "non-binary"]
  end
end