Ecto.Changeset.validations
You're seeing just the function
validations
, go back to Ecto.Changeset module for more information.
Specs
Returns a keyword list of the validations for this changeset.
The keys in the list are the names of fields, and the values are a validation associated with the field. A field may occur multiple times in the list.
Example
%Post{}
|> change()
|> validate_format(:title, ~r/^\w+:\s/, message: "must start with a topic")
|> validate_length(:title, max: 100)
|> validations()
#=> [
title: {:length, [ max: 100 ]},
title: {:format, ~r/^\w+:\s/}
]
The following validations may be included in the result. The list is not necessarily exhaustive. For example, custom validations written by the developer will also appear in our return value.
This first group contains validations that take a keyword list of validators,
where the validators are shown immediately following the validation type.
This list may also include a message:
key.
{:length, [option]}
min: n
max: n
is: n
count: :graphemes | :codepoints
{:number, [option]}
equal_to: n
greater_than: n
greater_than_or_equal_to: n
less_than: n
less_than_or_equal_to: n
The other validators simply take a value:
{:exclusion, Enum.t}
{:format, ~r/pattern/}
{:inclusion, Enum.t}
{:subset, Enum.t}