module Athena::Validator::Violation::ConstraintViolationInterface

Overview

Represents a violation of a constraint during validation.

Each failed constraint that fails during validation; one or more violations are created. The violations store the violation message, the path to the failing element, and the root element originally passed to the validator.

Direct including types

Defined in:

violation/constraint_violation_interface.cr

Instance Method Summary

Instance Method Detail

abstract def cause : String? #

Returns the cause of the violation.


[View source]
abstract def code : String? #

Returns a unique machine readable error code representing self. All constraints of a specific "type" should have the same code.


[View source]
abstract def constraint : AVD::Constraint? #

Returns the AVD::Constraint whose validation caused the violation, if any.


[View source]
abstract def invalid_value #

Returns the value that caused the violation.


[View source]
abstract def message : String #

Returns the violation message.


[View source]
abstract def message_template : String? #

Returns the raw violation message.

The message template contains placeholders for the parameters returned via #parameters.


[View source]
abstract def parameters : Hash(String, String) #

Returns the parameters used to render the #message_template.


[View source]
abstract def plural : Int32? #

Returns a number used to pluralize the violation message.

The returned value is used to determine the right plurlaization form.


[View source]
abstract def property_path : String #

Returns the path from the root element to the violation.


[View source]
abstract def root #

Returns the element originally passed to the validator.


[View source]
abstract def to_json(builder : JSON::Builder) : Nil #

Returns a JSON representation of self.


[View source]
abstract def to_s(io : IO) : Nil #

Returns a string representation of self.


[View source]