Oath (Oath v0.1.1) View Source
Oath provides a system for utilizing design by contract in elixir.
Pre and Post conditions
You can decorate any of your functions with preconditions and postconditions.
@decorator pre("inputs are ints", & is_integer(&1) && is_integer(&2))
@decorate post("the result must be greater than a or b", fn a, b, result ->
result >= a && result >= b
end)
def add(a, b) do
a + b
end
If your callers provide incorrect data or your function returns incorrect repsonses, an exception will be thrown.