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.



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

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.



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

def left
  @left
end

#messagesObject (readonly)

Returns the value of attribute messages.



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

def messages
  @messages
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#rightObject (readonly)

Returns the value of attribute right.



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

def right
  @right
end

Instance Method Details

#hint?Boolean

Returns:

  • (Boolean)


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

def hint?
  false
end

#root?Boolean

Returns:

  • (Boolean)


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

def root?
  path.empty?
end

#to_sObject



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

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