json_xema v0.1.4 JsonXema View Source

A JSON Schema validator.

Link to this section Summary

Functions

Returns true if the value is a valid value against the given schema; otherwise returns false

This function creates a new JsonXema from the given schema

Converts %JsonXema{} to %Xema{}

Returns true if the value is a valid value against the given schema; otherwise returns false

Returns :ok if the value is a valid value against the given schema; otherwise returns an error tuple

Returns :ok if the value is a valid value against the given schema; otherwise raises a Xema.ValidationError

Link to this section Types

Link to this type

t() View Source
t() :: %JsonXema{refs: any(), schema: any()}

Link to this section Functions

Link to this function

is_valid?(schema, value) View Source
is_valid?(JsonXema.t() | Xema.Schema.t(), any()) :: boolean()

This function is deprecated. Use valid? instead.

Returns true if the value is a valid value against the given schema; otherwise returns false.

Link to this function

new(data, opts \\ []) View Source
new(String.t() | map(), atom()) :: %JsonXema{refs: term(), schema: term()}

This function creates a new JsonXema from the given schema.

Possible options:

  • :resolver - a resolver for remote schemas. This option will overwrite the resolver from the config. See Configure a resolver to how to define a resolver.

Examples

iex> ~s({"type": "string"})
...> |> Jason.decode!()
...> |> JsonXema.new()
%JsonXema{refs: %{}, schema: %Xema.Schema{type: :string}}
Link to this function

to_xema(json_xema) View Source
to_xema(%JsonXema{refs: term(), schema: term()}) :: %Xema{
  refs: term(),
  schema: term()
}

Converts %JsonXema{} to %Xema{}.

Link to this function

valid?(schema, value) View Source
valid?(JsonXema.t() | Xema.Schema.t(), any()) :: boolean()

Returns true if the value is a valid value against the given schema; otherwise returns false.

Returns :ok if the value is a valid value against the given schema; otherwise returns an error tuple.

Link to this function

validate!(xema, value) View Source
validate!(JsonXema.t() | Xema.Schema.t(), any()) :: :ok

Returns :ok if the value is a valid value against the given schema; otherwise raises a Xema.ValidationError.