Skip to content

module Athena::Validator::Violation::ConstraintViolationInterface #

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

Athena::Validator::Violation::ConstraintViolation

Methods#

abstract #cause : String | ::Nil#

Returns the cause of the violation.

abstract #code : String | ::Nil#

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

abstract #constraint : AVD::Constraint | ::Nil#

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

abstract #invalid_value#

Returns the value that caused the violation.

abstract #message : String#

Returns the violation message.

abstract #message_template : String | ::Nil#

Returns the raw violation message.

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

abstract #parameters : Hash(String, String)#

Returns the parameters used to render the #message_template.

abstract #plural : Int32 | ::Nil#

Returns a number used to pluralize the violation message.

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

abstract #property_path : String#

Returns the path from the root element to the violation.

abstract #root#

Returns the element originally passed to the validator.

abstract #to_json(builder : JSON::Builder) : Nil#

Returns a JSON representation of self.

abstract #to_s(io : IO) : Nil#

Returns a string representation of self.