Class: Dry::Validation::Message::Or

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/validation/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right, messages) ⇒ Or

Returns a new instance of Or.



20
21
22
23
24
25
# File 'lib/dry/validation/message.rb', line 20

def initialize(left, right, messages)
  @left = left
  @right = right
  @messages = messages
  @path = left.path
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



12
13
14
# File 'lib/dry/validation/message.rb', line 12

def left
  @left
end

#messagesObject (readonly)

Returns the value of attribute messages.



18
19
20
# File 'lib/dry/validation/message.rb', line 18

def messages
  @messages
end

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/dry/validation/message.rb', line 16

def path
  @path
end

#rightObject (readonly)

Returns the value of attribute right.



14
15
16
# File 'lib/dry/validation/message.rb', line 14

def right
  @right
end

Instance Method Details

#hint?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/dry/validation/message.rb', line 27

def hint?
  false
end

#root?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/dry/validation/message.rb', line 31

def root?
  path.empty?
end

#to_sObject



35
36
37
# File 'lib/dry/validation/message.rb', line 35

def to_s
  [left, right].uniq.join(" #{messages[:or]} ")
end