JSONSchex.Sigil (jsonschex v0.6.0)

Copy Markdown View Source

Compile-time sigils for static JSON Schema literals.

The primary sigil is ~X, chosen to avoid the common ~J conflict with Jason while still feeling mnemonic for JSONSchex.

The sigil body is parsed as Elixir, not JSON, so the most ergonomic form is an Elixir map or boolean literal.

Examples

iex> import JSONSchex.Sigil, only: [sigil_X: 2]
iex> schema = ~X|%{"type" => "integer"}|
iex> JSONSchex.validate(schema, 1)
:ok

iex> import JSONSchex.Sigil, only: [sigil_X: 2]
iex> schema = ~X|%{"type" => "string", "format" => "email"}|f
iex> {:error, [_]} = JSONSchex.validate(schema, "not-an-email")

Summary

Functions

Imports the ~X sigil for compile-time schema literals.

Compile-time sigil for Elixir schema literals.

Functions

__using__(opts)

(macro)

Imports the ~X sigil for compile-time schema literals.

sigil_X(arg1, modifiers)

(macro)

Compile-time sigil for Elixir schema literals.

Supported modifiers:

  • fformat_assertion: true
  • ccontent_assertion: true