Class: KubeDSL::Validations::InclusionValidator
- Inherits:
-
Object
- Object
- KubeDSL::Validations::InclusionValidator
- Defined in:
- lib/kube-dsl/validations.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
-
#initialize(field_name, opts) ⇒ InclusionValidator
constructor
A new instance of InclusionValidator.
- #validate(obj, errors, nesting) ⇒ Object
Constructor Details
#initialize(field_name, opts) ⇒ InclusionValidator
153 154 155 156 |
# File 'lib/kube-dsl/validations.rb', line 153 def initialize(field_name, opts) @field_name = field_name @list = opts[:in] end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
151 152 153 |
# File 'lib/kube-dsl/validations.rb', line 151 def field_name @field_name end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
151 152 153 |
# File 'lib/kube-dsl/validations.rb', line 151 def list @list end |
Instance Method Details
#validate(obj, errors, nesting) ⇒ Object
158 159 160 161 162 |
# File 'lib/kube-dsl/validations.rb', line 158 def validate(obj, errors, nesting) unless list.include?(obj) errors.add([*nesting, field_name].join('.'), "is not in #{list.join(', ')}") end end |