Class: Vcloud::Core::ConfigValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/core/config_validator.rb

Constant Summary collapse

VALID_ALPHABETICAL_VALUES_FOR_IP_RANGE =
%w(Any external internal)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, data, schema) ⇒ ConfigValidator

Returns a new instance of ConfigValidator.



11
12
13
14
15
16
17
18
19
20
# File 'lib/vcloud/core/config_validator.rb', line 11

def initialize(key, data, schema)
  raise "Nil schema" unless schema
  raise "Invalid schema" unless schema.key?(:type)
  @type = schema[:type].to_s.downcase
  @errors = []
  @data   = data
  @schema = schema
  @key    = key
  validate
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/vcloud/core/config_validator.rb', line 7

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/vcloud/core/config_validator.rb', line 7

def errors
  @errors
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/vcloud/core/config_validator.rb', line 7

def key
  @key
end

#schemaObject (readonly)

Returns the value of attribute schema.



7
8
9
# File 'lib/vcloud/core/config_validator.rb', line 7

def schema
  @schema
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/vcloud/core/config_validator.rb', line 7

def type
  @type
end

Class Method Details

.validate(key, data, schema) ⇒ Object



26
27
28
# File 'lib/vcloud/core/config_validator.rb', line 26

def self.validate(key, data, schema)
  new(key, data, schema)
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/vcloud/core/config_validator.rb', line 22

def valid?
  @errors.empty?
end