Class: DecisionAgent::Dmn::Validator
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::Validator
- Defined in:
- lib/decision_agent/dmn/validator.rb
Overview
Validates DMN model structure and semantics with enhanced validation
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(model = nil) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
- #validate(model = nil) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(model = nil) ⇒ Validator
Returns a new instance of Validator.
12 13 14 15 16 17 |
# File 'lib/decision_agent/dmn/validator.rb', line 12 def initialize(model = nil) @model = model @errors = [] @warnings = [] @feel_evaluator = Feel::Evaluator.new end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'lib/decision_agent/dmn/validator.rb', line 10 def errors @errors end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
10 11 12 |
# File 'lib/decision_agent/dmn/validator.rb', line 10 def warnings @warnings end |
Instance Method Details
#valid? ⇒ Boolean
47 48 49 |
# File 'lib/decision_agent/dmn/validator.rb', line 47 def valid? @errors.empty? end |
#validate(model = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/decision_agent/dmn/validator.rb', line 19 def validate(model = nil) @model = model if model return unless @model @errors = [] @warnings = [] # Basic structure validation validate_model_structure validate_decisions # Semantic validation validate_decision_dependencies validate_decision_graph_cycles # Business rule validation validate_decision_tables nil end |
#validate! ⇒ Object
40 41 42 43 44 45 |
# File 'lib/decision_agent/dmn/validator.rb', line 40 def validate! validate raise InvalidDmnModelError, format_errors if @errors.any? nil end |