optimal v0.1.0 Optimal

Documentation for Optimal.

Link to this section Summary

Functions

Validates opts according to a schema or the constructor for a schema. Raises on invalid opts

Link to this section Types

Link to this type validation_result()
validation_result() :: {:ok, Keyword.t()} | {:error, [vex_error()]}
Link to this type vex_error()
vex_error() :: {:error, atom(), atom(), String.t()}

Link to this section Functions

Link to this function validate(opts, schema)
validate(opts :: Keyword.t(), schema :: Optimal.Schema.t()) ::
  {:ok, Keyword.t()} | {:error, [vex_error()]}
Link to this function validate!(opts, schema)
validate!(opts :: Keyword.t(), schema :: Optimal.Schema.t() | Keyword.t()) ::
  Keyword.t() | no_return()

Validates opts according to a schema or the constructor for a schema. Raises on invalid opts.

iex> Optimal.validate!([reticulate_splines?: true], allowed: [:reticulate_splines?])
[reticulate_splines?: true]
iex> Optimal.validate!([reticulate_splines?: true], allowed: [:load_textures?], additional_keys?: true)
[reticulate_splines?: true]
iex> schema = Optimal.schema(allowed: [:reticulate_splines?], required: [:reticulate_splines?], additional_keys?: true)
...> Optimal.validate!([reticulate_splines?: true, hack_interwebs?: true], schema)
[reticulate_splines?: true, hack_interwebs?: true]
iex> Optimal.validate!([], allowed: [:reticulate_splines?], required: [:reticulate_splines?])
** (ArgumentError) Opt Validation Error: reticulate_splines? - must be present