Class: DecisionAgent::EvaluationValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/evaluation_validator.rb

Overview

Validates evaluation objects for correctness and thread-safety

Defined Under Namespace

Classes: ValidationError

Class Method Summary collapse

Class Method Details

.validate!(evaluation) ⇒ Object

Validates a single evaluation

Parameters:

  • evaluation (Evaluation)

    the evaluation to validate

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/decision_agent/evaluation_validator.rb', line 11

def self.validate!(evaluation)
  raise ValidationError, "Evaluation cannot be nil" if evaluation.nil?
  raise ValidationError, "Evaluation must be an Evaluation instance" unless evaluation.is_a?(Evaluation)

  validate_decision!(evaluation.decision)
  validate_weight!(evaluation.weight)
  validate_reason!(evaluation.reason)
  validate_evaluator_name!(evaluation.evaluator_name)
  validate_frozen!(evaluation)

  true
end

.validate_all!(evaluations) ⇒ Object

Validates an array of evaluations

Parameters:

  • evaluations (Array<Evaluation>)

    the evaluations to validate

Raises:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/decision_agent/evaluation_validator.rb', line 27

def self.validate_all!(evaluations)
  raise ValidationError, "Evaluations must be an Array" unless evaluations.is_a?(Array)
  raise ValidationError, "Evaluations array cannot be empty" if evaluations.empty?

  evaluations.each_with_index do |evaluation, index|
    validate!(evaluation)
  rescue ValidationError => e
    raise ValidationError, "Validation failed for evaluation at index #{index}: #{e.message}"
  end

  true
end