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? cause, code : String? code, constraint : AVD::Constraint? constraint, invalid_value invalid_value, message : String message, message_template : String? message_template, parameters : Hash(String, String) parameters, plural : Int32? 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?, parameters : Hash(String, String), root : Root, property_path : String, invalid_value_container : AVD::Container, plural : Int32? = nil, code : String? = nil, constraint : AVD::Constraint? = nil, cause : String? = 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? #

Returns the cause of the violation.


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

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


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

: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? #

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? #

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]