optimal v0.3.6 Optimal.Schema View Source
Functions for generating and validating the opts that generate a schema.
Link to this section Summary
Link to this section Types
Link to this section Functions
Merges two optimal schemas to create a superset schema.
Opts
annotate
(:string
): Annotates the source of the opt, to be used in displaying documentation.add_required?
(:boolean
): “If true, all required fields from left/right are marked as required. Otherwise, only takes required fields from the left.”
Create a new schema.
Opts
opts
([{:list, :atom}, :keyword]
): A list of opts accepted, or a keyword of opt name to opt type - Default: []required
({:list, :atom}
): A list of required opts (all of which must be inopts
as well) - Default: []defaults
(:keyword
): A keyword list of option name to a default value. Values must pass type rules - Default: []extra_keys?
(:boolean
): If enabled, extra keys not specified by the schema do not fail validation - Default: falsecustom
(:keyword
): A keyword list of option name (for errors) and custom validations. See README - Default: []describe
(:keyword
): A keyword list of option names to short descriptions (like these) - Default: []
A custom validation is run on the types provided at schema creation time, to ensure they are all valid types.