Module: KubeDSL::Validations::InstanceMethods
- Defined in:
- lib/kube-dsl/validations.rb
Instance Method Summary collapse
Instance Method Details
#valid? ⇒ Boolean
220 221 222 223 |
# File 'lib/kube-dsl/validations.rb', line 220 def valid? errors = validate errors.empty? end |
#validate(errors = nil, nesting = []) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/kube-dsl/validations.rb', line 195 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
210 211 212 213 214 215 216 217 218 |
# File 'lib/kube-dsl/validations.rb', line 210 def validate! errors = validate unless errors.empty? field = errors..keys.first = errors.[field].first raise ValidationError, "#{field} #{}" end end |