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.

View source

abstract #code : String | ::Nil#

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

View source

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

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

View source

abstract #invalid_value#

Returns the value that caused the violation.

View source

abstract #message : String#

Returns the violation message.

View source

abstract #message_template : String | ::Nil#

Returns the raw violation message.

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

View source

abstract #parameters : Hash(String, String)#

Returns the parameters used to render the #message_template.

View source

abstract #plural : Int32 | ::Nil#

Returns a number used to pluralize the violation message.

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

View source

abstract #property_path : String#

Returns the path from the root element to the violation.

View source

abstract #root#

Returns the element originally passed to the validator.

View source

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

Returns a JSON representation of self.

View source

abstract #to_s(io : IO) : Nil#

Returns a string representation of self.

View source