optimal v0.3.3 Optimal View Source

Documentation for Optimal.

Link to this section Summary

Link to this section Types

Link to this type validation_result() View Source
validation_result() :: {:ok, Keyword.t()} | {:error, [error()]}

Link to this section Functions

Link to this function merge(left, right, opts) View Source
Link to this function validate(opts, schema) View Source
validate(opts :: Keyword.t(), schema :: Optimal.Schema.t()) ::
  {:ok, Keyword.t()} | {:error, [error()]}
Link to this function validate!(opts, schema) View Source
validate!(opts :: Keyword.t(), schema :: schema()) :: 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], opts: [:reticulate_splines?])
[reticulate_splines?: true]
iex> Optimal.validate!([reticulate_splines?: true], opts: [:load_textures?], extra_keys?: true)
[reticulate_splines?: true]
iex> schema = Optimal.schema(opts: [:reticulate_splines?], required: [:reticulate_splines?], extra_keys?: true)
...> Optimal.validate!([reticulate_splines?: true, hack_interwebs?: true], schema)
[reticulate_splines?: true, hack_interwebs?: true]
iex> Optimal.validate!([], opts: [:reticulate_splines?], required: [:reticulate_splines?])
** (ArgumentError) Opt Validation Error: reticulate_splines? - is required