ash v1.34.7 Ash.Resource.Validation.Builtins View Source

Built in validations that are available to all resources

The functions in this module are imported by default in the validations section.

Link to this section Summary

Functions

Validates the absence of a list of attributes

Validates that an attribute on the original record does not equal a specific value

Validates that an attribute on the original record equals a specific value

Validates that an attribute is being changed

Validates that a field or argument matches another field or argument

Validates that an attribute's value matches a given regex or string, using the provided error, message if not.

Validates that an attribute's value is in a given list

Validates the presence of a list of attributes

Validates that an attribute on the original record meets the given length criteria

Link to this section Functions

Link to this function

absent(attributes, opts \\ [])

View Source

Validates the absence of a list of attributes

If no options are provided, validates that they are all absent.

The docs behave the same as present/2, except they validate absence.

Link to this function

attribute_does_not_equal(attribute, value)

View Source

Validates that an attribute on the original record does not equal a specific value

Link to this function

attribute_equals(attribute, value)

View Source

Validates that an attribute on the original record equals a specific value

Validates that an attribute is being changed

Link to this function

confirm(field, confirmation)

View Source

Validates that a field or argument matches another field or argument

Link to this function

match(attribute, match, message \\ nil)

View Source

Validates that an attribute's value matches a given regex or string, using the provided error, message if not.

String.match?/2 is used to determine if it matches.

Link to this function

one_of(attribute, values)

View Source

Validates that an attribute's value is in a given list

Link to this function

present(attributes, opts \\ [])

View Source

Validates the presence of a list of attributes

If no options are provided, validates that they are all present.

  • :at_least - At least this many must be present. Defaults to the number of attributes provided

  • :at_most - At most this many must be present. Defaults to the number of attributes provided

  • :exactly - Exactly this many must be present

Link to this function

string_length(attribute, opts \\ [])

View Source

Validates that an attribute on the original record meets the given length criteria