Module: KubeDSL::Validations::InstanceMethods
- Defined in:
- lib/kube-dsl/validations.rb
Instance Method Summary collapse
Instance Method Details
#valid? ⇒ Boolean
216 217 218 219 |
# File 'lib/kube-dsl/validations.rb', line 216 def valid? errors = validate errors.empty? end |
#validate(errors = nil, nesting = []) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/kube-dsl/validations.rb', line 191 def validate(errors = nil, nesting = []) errors ||= ValidationErrors.new self.class.validators.each do |field_name, validators| field = send(field_name) validators.each { |val| val.validate(field, errors, nesting) } if field.respond_to?(:validate) field.validate(errors, nesting + [field_name.to_s]) end end errors end |
#validate! ⇒ Object
206 207 208 209 210 211 212 213 214 |
# File 'lib/kube-dsl/validations.rb', line 206 def validate! errors = validate unless errors.empty? field = errors..keys.first = errors.[field].first raise ValidationError, "#{field} #{}" end end |