View Source Rivet.Utils.Ecto.Changeset (rivet_utils v1.1.8)

extensions for ecto change sets

Contributor: Brandon Gillespie

Link to this section Summary

Functions

If the key exists in the changeset, make sure it's a clean value

For a value that is a list of maps, validate each element with func

Convert keys map to atoms

(replacement for validate_format, which supports negation)

free-form updating, like a map

Link to this section Functions

Link to this function

validate_clean_atom(chgset, key)

View Source

If the key exists in the changeset, make sure it's a clean value

Link to this function

validate_each(chgset, key, func)

View Source

For a value that is a list of maps, validate each element with func

Link to this function

validate_map(chgset, key)

View Source

Convert keys map to atoms

Link to this function

validate_rex(changeset, field, format, opts \\ [])

View Source

(replacement for validate_format, which supports negation)

Validates a change has the given format.

The format has to be expressed as a regular expression.

options

Options

  • :message - the message on failure, defaults to "has invalid format"
  • :not - invert match for truth. default is false

examples

Examples

validate_rex(changeset, :email, ~r/@/)
validate_rex(changeset, :thing, ~r/[^a-z0-9]/, not: true)
Link to this function

validate_update(changeset, field, fun)

View Source

free-form updating, like a map