Class: KubeDSL::Validations::ObjectValidator
- Inherits:
-
Object
- Object
- KubeDSL::Validations::ObjectValidator
- Defined in:
- lib/kube-dsl/validations.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#kind_of ⇒ Object
readonly
Returns the value of attribute kind_of.
Instance Method Summary collapse
-
#initialize(field_name, opts) ⇒ ObjectValidator
constructor
A new instance of ObjectValidator.
- #validate(obj, errors, nesting) ⇒ Object
Constructor Details
#initialize(field_name, opts) ⇒ ObjectValidator
Returns a new instance of ObjectValidator.
115 116 117 118 |
# File 'lib/kube-dsl/validations.rb', line 115 def initialize(field_name, opts) @field_name = field_name @kind_of = opts.fetch(:kind_of) end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
113 114 115 |
# File 'lib/kube-dsl/validations.rb', line 113 def field_name @field_name end |
#kind_of ⇒ Object (readonly)
Returns the value of attribute kind_of.
113 114 115 |
# File 'lib/kube-dsl/validations.rb', line 113 def kind_of @kind_of end |
Instance Method Details
#validate(obj, errors, nesting) ⇒ Object
120 121 122 123 124 |
# File 'lib/kube-dsl/validations.rb', line 120 def validate(obj, errors, nesting) unless obj.nil? || obj.is_a?(kind_of) errors.add([*nesting, field_name].join('.'), "'#{obj.class.name}', expected '#{kind_of.name}'") end end |