Class: Validate::Constraint::Violation

Inherits:
Object
  • Object
show all
Defined in:
lib/validate/constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, path, constraint) ⇒ Violation

Returns a new instance of Violation.



9
10
11
12
13
# File 'lib/validate/constraint.rb', line 9

def initialize(value, path, constraint)
  @value = value
  @path = path
  @constraint = constraint
end

Instance Attribute Details

#constraintObject (readonly)

Returns the value of attribute constraint.



7
8
9
# File 'lib/validate/constraint.rb', line 7

def constraint
  @constraint
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/validate/constraint.rb', line 7

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/validate/constraint.rb', line 7

def value
  @value
end

Instance Method Details

#message(template = @constraint.message) ⇒ Object Also known as: to_s



15
16
17
# File 'lib/validate/constraint.rb', line 15

def message(template = @constraint.message)
  (template % parameters).strip
end