Class: Maze::Schemas::ConfigValidator

Inherits:
ValidatorBase show all
Defined in:
lib/maze/schemas/config_validator.rb

Constant Summary

Constants inherited from ValidatorBase

ValidatorBase::HEX_STRING_16, ValidatorBase::HEX_STRING_32, ValidatorBase::HOUR_TOLERANCE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ValidatorBase

#each_element_contains, #each_element_contains_each, #each_element_exists, #each_event_contains, #each_event_contains_each, #element_a_greater_or_equal_element_b, #element_exists, #element_has_value, #element_int_in_range, #regex_comparison, #validate_header, #validate_timestamp

Constructor Details

#initialize(request, validation_block) ⇒ ConfigValidator

Returns a new instance of ConfigValidator.



15
16
17
18
# File 'lib/maze/schemas/config_validator.rb', line 15

def initialize(request, validation_block)
  super(request)
  @validation_block = validation_block
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



13
14
15
# File 'lib/maze/schemas/config_validator.rb', line 13

def body
  @body
end

#errorsObject

Returns the value of attribute errors.



11
12
13
# File 'lib/maze/schemas/config_validator.rb', line 11

def errors
  @errors
end

#headersObject (readonly)

Returns the value of attribute headers.



12
13
14
# File 'lib/maze/schemas/config_validator.rb', line 12

def headers
  @headers
end

#successObject

Returns the value of attribute success.



10
11
12
# File 'lib/maze/schemas/config_validator.rb', line 10

def success
  @success
end

Instance Method Details

#validateObject



20
21
22
23
24
25
26
27
# File 'lib/maze/schemas/config_validator.rb', line 20

def validate
  @success = true
  @validation_block.call(self)
rescue => exception
  @success = false
  @errors << "A #{exception.class} occurred while running validation: #{exception.message}, \n #{exception.backtrace.join("\n")}" 

end