struct Athena::Validator::Violation::ConstraintViolation(Root)

Overview

Basic implementation of AVD::Violation::ConstraintViolationInterface.

Included Modules

Defined in:

violation/constraint_violation.cr

Constructors

Instance Method Summary

Instance methods inherited from module Athena::Validator::Violation::ConstraintViolationInterface

cause : String | Nil cause, code : String | Nil code, constraint : AVD::Constraint | Nil constraint, invalid_value invalid_value, message : String message, message_template : String | Nil message_template, parameters : Hash(String, String) parameters, plural : Int32 | Nil plural, property_path : String property_path, root root, to_json(builder : JSON::Builder) : Nil to_json, to_s(io : IO) : Nil to_s

Constructor Detail

def self.new(message : String, message_template : String | Nil, parameters : Hash(String, String), root : 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]

Instance Method Detail

def ==(other : self) : Bool #

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


[View source]
def cause : String | Nil #

Returns the cause of the violation.


[View source]
def 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]
def constraint : AVD::Constraint #

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


[View source]
def constraint? : AVD::Constraint | Nil #

:inherit:


[View source]
def invalid_value #

Returns the value that caused the violation.


[View source]
def message : String #

Returns the violation message.


[View source]
def message_template : String | Nil #

Returns the raw violation message.

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


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

Returns the parameters used to render the #message_template.


[View source]
def 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]
def property_path : String #

Returns the path from the root element to the violation.


[View source]
def root : Root #

Returns the element originally passed to the validator.


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

Returns a JSON representation of self.


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

Returns a string representation of self.


[View source]