Skip to content

struct Athena::Validator::Violation::ConstraintViolation
inherits Struct #

Basic implementation of AVD::Violation::ConstraintViolationInterface.

Included modules

Athena::Validator::Violation::ConstraintViolationInterface

Constructors#

.new(message : String, message_template : String | Nil, parameters : Hash(String, String), root : _, property_path : String, invalid_value_container : AVD::Container, plural : Int32 | Nil = nil, code : String | Nil = nil, constraint : AVD::Constraint | Nil = nil, cause : String | Nil = nil)#

View source

Methods#

#==(other : AVD::Violation::ConstraintViolationInterface) : Bool#

Returns true if other is the same as self, otherwise false.

View source

#cause : String | ::Nil#

Returns the cause of the violation.

View source

#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

#constraint : AVD::Constraint#

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

View source

#constraint? : AVD::Constraint | ::Nil#

:inherit:

View source

#invalid_value#

Returns the value that caused the violation.

View source

#message : String#

Returns the violation message.

View source

#message_template : String | ::Nil#

Returns the raw violation message.

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

View source

#parameters : Hash(String, String)#

Returns the parameters used to render the #message_template.

View source

#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

#property_path : String#

Returns the path from the root element to the violation.

View source

#root#

Returns the element originally passed to the validator.

View source

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

Returns a JSON representation of self.

View source

#to_s(io : IO) : Nil#

Returns a string representation of self.

View source