Xema.Builder.all_of
You're seeing just the function
all_of
, go back to Xema.Builder module for more information.
Specs
all_of(type, [schema]) :: {type, [{:all_of, [schema]}]} when type: Xema.Schema.type(), schema: Xema.Schema.t() | Xema.Schema.type() | tuple() | atom() | keyword()
Returns a tuple with the given type
(default :any
) and the given schemas
tagged by the keyword :all_of
. This function provides a shortcut for
something like integer(all_of: [...])
or any(all_of: [...])
.
Examples
iex> Xema.Builder.all_of([:integer, :string])
{:any, all_of: [:integer, :string] }
iex> Xema.Builder.all_of(:integer, [[minimum: 10], [maximum: 5]])
{:integer, all_of: [[minimum: 10], [maximum: 5]]}
defmodule MySchema do
use Xema
xema do
all_of [
list(items: integer(minimum: 1, maximum: 66)),
list(items: integer(minimum: 33, maximum: 100))
]
end
end
MySchema.valid?([20, 30]) #=> false
MySchema.valid?([40, 50]) #=> true
MySchema.valid?([60, 70]) #=> false
MySchema.valid?([10, 90]) #=> false