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
Returns a new instance of InclusionValidator.
149 150 151 152 |
# File 'lib/kube-dsl/validations.rb', line 149 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.
147 148 149 |
# File 'lib/kube-dsl/validations.rb', line 147 def field_name @field_name end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
147 148 149 |
# File 'lib/kube-dsl/validations.rb', line 147 def list @list end |
Instance Method Details
#validate(obj, errors, nesting) ⇒ Object
154 155 156 157 158 |
# File 'lib/kube-dsl/validations.rb', line 154 def validate(obj, errors, nesting) unless list.include?(obj) errors.add([*nesting, field_name].join('.'), "is not in #{list.join(', ')}") end end |