#
View Source Ash.Resource.Validation behaviour (ash v2.14.2)

Represents a validation in Ash.

See `Ash.Resource.Validation.Builtins` for a list of builtin validations.

To write your own validation, define a module that implements the `init/1` callback to validate options at compile time, and `validate/2` callback to do the validation.

Then, in a resource, you can say:

    validations do
      validate {MyValidation, [foo: :bar]}
    end

# Link to this section Summary

## Types

path()
ref()
t()

## Callbacks

describe(t)
init(t)
validate(t, t)

## Functions

action_schema()
on(list)
opt_schema()
validation_type()

# Link to this section Types

Link to this type

# path()

View Source

    @type path() :: [atom() | integer()]

Link to this type

# ref()

View Source

    @type ref() :: {module(), Keyword.t()} | module()

Link to this type

# t()

View Source

    @type t() :: %Ash.Resource.Validation{
      before_action?: term(),
      description: String.t() | nil,
      message: term(),
      module: atom(),
      on: [atom()],
      only_when_valid?: boolean(),
      opts: [atom()],
      validation: {atom(), [atom()]},
      where: [{atom(), [atom()]}]
    }

# Link to this section Callbacks

Link to this callback

# describe(t)

View Source (optional)

    @callback describe(Keyword.t()) :: [message: String.t(), vars: Keyword.t()]

Link to this callback

# init(t)

View Source

    @callback init(Keyword.t()) :: {:ok, Keyword.t()} | {:error, String.t()}

Link to this callback

# validate(t, t)

View Source

    @callback validate(Ash.Changeset.t(), Keyword.t()) :: :ok | {:error, term()}

# Link to this section Functions

Link to this function

# action_schema()

View Source
Link to this function

# on(list)

View Source
Link to this function

# opt_schema()

View Source
Link to this function

# validation_type()

View Source