validex v0.6.0 Validex.Validators.Presence
The Presence validator is used for validating the presence of values, the empty string in addition to any value not included in a map is considered absence.
In addition to validating presence the validator function as a Validex.RuleExpander
which expands rules to include presence by default if it hasn’t been specified otherwise.
Examples
iex> Validex.Validators.Presence.validate(:presence, :name, true, "", [])
[{:error, :name, :presence, "name is a required attribute but was absent"}]
iex> Validex.Validators.Presence.validate(:presence, :name, true, :__validex_missing__, [])
[{:error, :name, :presence, "name is a required attribute but was absent"}]
iex> Validex.Validators.Presence.validate(:presence, :name, false, "", [])
[]
iex> Validex.Validators.Presence.expand([type: :string])
[presence: :__validex_default_presence, type: :string]
iex> Validex.Validators.Presence.expand([presence: false, type: :string])
[presence: false, type: :string]
Summary
Functions
Callback implementation for Validex.RuleExpander.expand/1
Callback implementation for Validex.Validator.rule_kind/0
Callback implementation for Validex.Validator.validate/5
Functions
Callback implementation for Validex.RuleExpander.expand/1
.
Callback implementation for Validex.Validator.rule_kind/0
.
Callback implementation for Validex.Validator.validate/5
.