Sinter.ValidationError exception (Sinter v0.0.1)

View Source

Exception raised by validate! functions when validation fails.

This exception contains the validation errors that caused the failure, allowing the caller to access detailed error information programmatically.

Summary

Functions

Gets the validation errors from the exception.

Creates a new ValidationError from a list of errors.

Formats the validation error for display.

Types

t()

@type t() :: %Sinter.ValidationError{
  __exception__: true,
  errors: [Sinter.Error.t()],
  message: String.t()
}

Functions

errors(validation_error)

@spec errors(t()) :: [Sinter.Error.t()]

Gets the validation errors from the exception.

exception(msg)

@spec exception(keyword()) :: t()

Creates a new ValidationError from a list of errors.

Examples

iex> errors = [Sinter.Error.new([:name], :required, "field is required")]
iex> raise Sinter.ValidationError, errors: errors

format(validation_error)

@spec format(t()) :: String.t()

Formats the validation error for display.