generated from athena-framework/component-template
/
constraint_violation_builder_interface.cr
48 lines (40 loc) · 2.23 KB
/
constraint_violation_builder_interface.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# A [Builder Pattern](https://en.wikipedia.org/wiki/Builder_pattern) type for building `AVD::Violation::ConstraintViolationInterface`s.
#
# Allows using the methods defined on `self` to construct the desired violation before adding it to the context.
module Athena::Validator::Violation::ConstraintViolationBuilderInterface
# Adds the violation to the current `AVD::ExecutionContextInterface`.
abstract def add : Nil
# Adds a parameter with the provided *key* and *value* to the violations' `AVD::Violation::ConstraintViolationInterface#parameters`.
# The provided *value* is stringified via `#to_s` before being added to the parameters.
#
# Returns `self` for chaining.
abstract def add_parameter(key : String, value : _) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets the `AVD::Violation::ConstraintViolationInterface#property_path`.
#
# Returns `self` for chaining.
abstract def at_path(path : String) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets the `AVD::Violation::ConstraintViolationInterface#cause`
#
# Returns `self` for chaining.
abstract def cause(cause : String?) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets the `AVD::Violation::ConstraintViolationInterface#code`
#
# Returns `self` for chaining.
abstract def code(code : String?) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets the `AVD::Violation::ConstraintViolationInterface#constraint`
#
# Returns `self` for chaining.
abstract def constraint(constraint : AVD::Constraint?) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets the `AVD::Violation::ConstraintViolationInterface#invalid_value`
#
# Returns `self` for chaining.
abstract def invalid_value(value : _) : AVD::Violation::ConstraintViolationBuilderInterface
# Sets `AVD::Violation::ConstraintViolationInterface#plural`
#
# Returns `self` for chaining.
abstract def plural(number : Int32) : AVD::Violation::ConstraintViolationBuilderInterface
# Overrides the entire `AVD::Violation::ConstraintViolationInterface#parameters` hash with the provided *parameters*.
#
# Returns `self` for chaining.
abstract def set_parameters(parameters : Hash(String, String)) : AVD::Violation::ConstraintViolationBuilderInterface
end