Class: DecisionAgent::Dsl::SchemaValidator

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

Overview

JSON Schema validator for Decision Agent rule DSL Provides comprehensive validation with detailed error messages

Constant Summary collapse

SUPPORTED_OPERATORS =
%w[
  eq neq gt gte lt lte in present blank
  contains starts_with ends_with matches
  between modulo
  sin cos tan asin acos atan atan2
  sinh cosh tanh
  sqrt cbrt power exp log log10 log2
  round floor ceil truncate abs
  factorial gcd lcm
  min max sum average mean median stddev standard_deviation variance percentile count
  before_date after_date within_days day_of_week
  duration_seconds duration_minutes duration_hours duration_days
  add_days subtract_days add_hours subtract_hours add_minutes subtract_minutes
  hour_of_day day_of_month month year week_of_year
  rate_per_second rate_per_minute rate_per_hour
  moving_average moving_sum moving_max moving_min
  compound_interest present_value future_value payment
  join length
  contains_all contains_any intersects subset_of
  within_radius in_polygon
].freeze
CONDITION_TYPES =
%w[all any field].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SchemaValidator

Returns a new instance of SchemaValidator.



37
38
39
40
# File 'lib/decision_agent/dsl/schema_validator.rb', line 37

def initialize(data)
  @data = data
  @errors = []
end

Class Method Details

.validate!(data) ⇒ Object

Validates the entire ruleset structure



33
34
35
# File 'lib/decision_agent/dsl/schema_validator.rb', line 33

def self.validate!(data)
  new(data).validate!
end

Instance Method Details

#validate!Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/decision_agent/dsl/schema_validator.rb', line 42

def validate!
  validate_root_structure
  validate_version
  validate_rules_array
  validate_each_rule

  raise InvalidRuleDslError, format_errors if @errors.any?

  true
end