class

Ralph::Validations::ValidationError

Inherits Reference / Object

Represents a single validation error with structured data

This class provides i18n-ready error information with error codes and interpolation options for generating translated messages.

Example

error = ValidationError.new(:blank)
error.message # => "can't be blank"

error = ValidationError.new(:too_short, count: 3)
error.message # => "is too short (minimum is 3 characters)"
error.options # => {count: 3}

Constructors

new(code : Symbol, message : String = "", **opts)
Source

Instance methods

==(other : ValidationError) : Bool

Compare errors by code

Source
code

The error code (e.g., :blank, :too_short, :invalid)

Source
message

The human-readable message

Source
options

Additional options for interpolation (e.g., count, minimum, maximum)

Source
to_s

Convert to a simple string for backward compatibility

Source