Class: Dry::Validation::Rust::Message
- Inherits:
-
Data
- Object
- Data
- Dry::Validation::Rust::Message
- Defined in:
- lib/dry/validation/rust/message.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #base? ⇒ Boolean
-
#initialize(text:, path:, meta: {}, code: nil, source: :rule, predicate: nil, args: []) ⇒ Message
constructor
A new instance of Message.
- #payload ⇒ Object
- #rule? ⇒ Boolean
- #schema? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(text:, path:, meta: {}, code: nil, source: :rule, predicate: nil, args: []) ⇒ Message
Returns a new instance of Message.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dry/validation/rust/message.rb', line 7 def initialize(text:, path:, meta: {}, code: nil, source: :rule, predicate: nil, args: []) super( text: text.to_s.freeze, path: Array(path).freeze, meta: .freeze, code: code&.to_sym, source: source, predicate: predicate&.to_sym, args: args.freeze ) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def args @args end |
#code ⇒ Object (readonly)
Returns the value of attribute code
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def code @code end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def @meta end |
#path ⇒ Object (readonly)
Returns the value of attribute path
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def path @path end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def predicate @predicate end |
#source ⇒ Object (readonly)
Returns the value of attribute source
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def source @source end |
#text ⇒ Object (readonly)
Returns the value of attribute text
6 7 8 |
# File 'lib/dry/validation/rust/message.rb', line 6 def text @text end |
Instance Method Details
#base? ⇒ Boolean
19 20 21 |
# File 'lib/dry/validation/rust/message.rb', line 19 def base? path.compact.empty? end |
#payload ⇒ Object
31 32 33 |
# File 'lib/dry/validation/rust/message.rb', line 31 def payload .empty? ? text : { text: text, ** } end |
#rule? ⇒ Boolean
27 28 29 |
# File 'lib/dry/validation/rust/message.rb', line 27 def rule? source == :rule end |
#schema? ⇒ Boolean
23 24 25 |
# File 'lib/dry/validation/rust/message.rb', line 23 def schema? source == :schema end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/dry/validation/rust/message.rb', line 35 def to_s text end |