Class: EmbeddedRecordsValidation
- Inherits:
-
Validation
- Object
- Validation
- EmbeddedRecordsValidation
- Defined in:
- lib/yodel/models/core/validations/embedded_records_validation.rb
Instance Attribute Summary
Attributes inherited from Validation
Class Method Summary collapse
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(params, errors) ⇒ EmbeddedRecordsValidation
constructor
A new instance of EmbeddedRecordsValidation.
Methods inherited from Validation
Constructor Details
#initialize(params, errors) ⇒ EmbeddedRecordsValidation
Returns a new instance of EmbeddedRecordsValidation.
2 3 4 5 |
# File 'lib/yodel/models/core/validations/embedded_records_validation.rb', line 2 def initialize(params, errors) super(params) @errors = errors end |
Class Method Details
.validate(field, records, record, errors) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yodel/models/core/validations/embedded_records_validation.rb', line 7 def self.validate(field, records, record, errors) # embedded record validations records = [records] unless records.respond_to?(:to_a) = Errors.new records.to_a.each_with_index do |, index| [index] = .valid? ? nil : .errors end # field set validations field.fields.each do |name, | next unless .set_validations set_value = records.to_a.collect {|| .get(name)}.uniq .set_validations.each do |type, params| Validation.validate(type, params, , name, set_value, record, ) end end errors[field.name] = unless .empty? end |
Instance Method Details
#describe ⇒ Object
27 28 29 30 |
# File 'lib/yodel/models/core/validations/embedded_records_validation.rb', line 27 def describe # FIXME: don't just call inspect here, format correctly using describe calls "has these errors: #{@errors.inspect}}" end |