View Source JsonXema (json_xema v0.6.4)
A JSON Schema validator.
Summary
Types
The return type of a validation run.
This struct contains the schema and references of the schema.
Functions
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 Elixir.JsonXema.ValidationError
. See validate3
for
available options.
Types
@type result() :: Xema.Validator.result()
The return type of a validation run.
@type schema() :: Xema.Schema.t()
@type t() :: %JsonXema{refs: map(), schema: Xema.Schema.t()}
This struct contains the schema and references of the schema.
Functions
This function creates a new JsonXema
from the given schema
.
Possible options:
:loader
- a loader for remote schemas. This option will overwrite the loader from the config. See Configure a loader to how to define a loader.
Examples
iex> ~s({"type": "string"})
...> |> Jason.decode!()
...> |> JsonXema.new()
%JsonXema{refs: %{}, schema: %Xema.Schema{type: :string}}
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.
With the option :fail
, you can define when the validation is aborted. This
also influences how many error reasons are returned.
:immediately
aborts the validation when the first validation fails.:early
(default) aborts on failed validations, but runs validations for all properties and items.:finally
aborts after all possible validations.
Returns :ok
if the value
is a valid value against the given schema
;
otherwise raises a Elixir.JsonXema.ValidationError
. See validate3
for
available options.