Class: Vcloud::Core::ConfigValidator
- Inherits:
-
Object
- Object
- Vcloud::Core::ConfigValidator
- 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
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, data, schema) ⇒ ConfigValidator
constructor
A new instance of ConfigValidator.
- #valid? ⇒ Boolean
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/vcloud/core/config_validator.rb', line 7 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/vcloud/core/config_validator.rb', line 7 def errors @errors end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/vcloud/core/config_validator.rb', line 7 def key @key end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/vcloud/core/config_validator.rb', line 7 def schema @schema end |
#type ⇒ Object (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
22 23 24 |
# File 'lib/vcloud/core/config_validator.rb', line 22 def valid? @errors.empty? end |