Class: MendixBridge::Validator
- Inherits:
-
Object
- Object
- MendixBridge::Validator
- Defined in:
- lib/mendix_bridge/validator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model) ⇒ Validator
constructor
A new instance of Validator.
- #validate! ⇒ Object
Constructor Details
#initialize(model) ⇒ Validator
Returns a new instance of Validator.
11 12 13 |
# File 'lib/mendix_bridge/validator.rb', line 11 def initialize(model) @model = model end |
Class Method Details
.validate!(model) ⇒ Object
7 8 9 |
# File 'lib/mendix_bridge/validator.rb', line 7 def self.validate!(model) new(model).validate! end |
Instance Method Details
#validate! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mendix_bridge/validator.rb', line 15 def validate! errors = [] entities = entity_index @model.modules.each do |app_module| app_module.entities.each do |entity| entity.associations.each do |association| next if entities.include?(association.target) errors << "#{app_module.name}.#{entity.name}.#{association.name} " \ "targets unknown entity #{association.target}" end end end raise ValidationError, errors.join("\n") unless errors.empty? @model end |