xema v0.2.0 Xema.Schema View Source
This module contains the struct for the keywords of a schema.
Usually this struct will be just used by xema
.
Examples
iex> schema = Xema.new :any
%Xema{content: %Xema.Schema{type: :any, as: :any}}
iex> schema.content == %Xema.Schema{type: :any, as: :any}
true
Link to this section Summary
Link to this section Types
Link to this type
t()
View Source
t() :: %Xema.Schema{additional_items: Xema.t() | Xema.Schema.t() | boolean() | nil, additional_properties: map() | boolean() | nil, all_of: term(), any_of: term(), as: atom(), dependencies: list() | map() | nil, enum: list() | nil, exclusive_maximum: boolean() | number() | nil, exclusive_minimum: boolean() | number() | nil, items: list() | Xema.t() | Xema.Schema.t() | nil, keys: atom() | nil, max_items: pos_integer() | nil, max_length: pos_integer() | nil, max_properties: pos_integer() | nil, maximum: number() | nil, min_items: pos_integer() | nil, min_length: pos_integer() | nil, min_properties: pos_integer() | nil, minimum: number() | nil, multiple_of: number() | nil, not: term(), one_of: term(), pattern: Regex.t() | nil, pattern_properties: map() | nil, properties: map() | nil, required: MapSet.t() | nil, type: atom(), unique_items: boolean() | nil}
The struct contains the keywords for a schema.
additional_items
disallow additional items, if set to false. The keyword can also contain a schema to specify the type of additional items.additional_properties
disallow additional properties, if set to true.as
is used in an error report.as
is used in an error report. Default ofas
is:list
.dependencies
allows the schema of the map to change based on the presence of certain special propertiesenum
specifies an enumerationexclusive_maximum
is a boolean. When true, it indicates that the range excludes the maximum value.exclusive_minimum
is a boolean. When true, it indicates that the range excludes the minimum value.items
specifies the type(s) of the items.keys
could be:atoms
or:strings
.max_items
the maximum length of list.max_length
the maximum length of string.max_properties
the maximum count of properties for the map.maximum
the maximum value.min_items
the minimal length of list.min_length
the minimal length of string.min_properties
the minimal count of properties for the map.minimum
the minimum value.multiple_of
is a number greater 0. The value has to be a multiple of this number.one_of
the given data must be valid against exactly one of the given subschemas.pattern_properties
specifies schemas for properties by patternspattern
restrict a string to a particular regular expression.properties
specifies schemas for properties.required
contains a set of required properties.type
specifies the data type for a schema.unique_items
disallow duplicate items, if set to true.
Link to this section Functions
Link to this function
to_string(schema, opts \\ [])
View Source
to_string(any(), keyword()) :: String.t()