Validates the options given to strategies and recover modules.
The built-in modules use it in their init/1, and custom ones can too, so
that invalid options fail the same way: with an ArgumentError that
Rexsilient raises again with the declaration's name.
@impl true
def init(opts) do
Rexsilient.Options.validate!(opts, delay: :non_neg_integer, budget: :pos_integer)
end
Summary
Functions
Validates opts against spec, a keyword list of key: type.
Types
Functions
Validates opts against spec, a keyword list of key: type.
Every key in spec is required, and keys not in spec are rejected.
Returns the options as a map. Raises ArgumentError otherwise.
Examples
Rexsilient.Options.validate!([threshold: 5], threshold: :pos_integer)
#=> %{threshold: 5}
Rexsilient.Options.validate!([threshold: 0], threshold: :pos_integer)
** (ArgumentError) threshold must be a positive integer, got: 0