Class: RubyLLM::Contract::SchemaValidator::BoundRule
- Inherits:
-
Object
- Object
- RubyLLM::Contract::SchemaValidator::BoundRule
- Defined in:
- lib/ruby_llm/contract/contract/schema_validator/bound_rule.rb
Overview
Validates numeric and collection size bounds for a node.
Constant Summary collapse
- NUMERIC_LIMITS =
[ { key: :minimum, label: "minimum", relation: "below", invalid: ->(actual, limit) { actual < limit } }, { key: :maximum, label: "maximum", relation: "above", invalid: ->(actual, limit) { actual > limit } } ].freeze
- SIZE_LIMITS =
[ { bound: :min_key, relation: "below", invalid: ->(actual, limit) { actual < limit } }, { bound: :max_key, relation: "above", invalid: ->(actual, limit) { actual > limit } } ].freeze
Instance Method Summary collapse
-
#initialize(errors) ⇒ BoundRule
constructor
A new instance of BoundRule.
- #validate(node) ⇒ Object
Constructor Details
#initialize(errors) ⇒ BoundRule
Returns a new instance of BoundRule.
17 18 19 |
# File 'lib/ruby_llm/contract/contract/schema_validator/bound_rule.rb', line 17 def initialize(errors) @errors = errors end |
Instance Method Details
#validate(node) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ruby_llm/contract/contract/schema_validator/bound_rule.rb', line 21 def validate(node) value = node.value schema = node.schema path = node.path append_numeric_bound_errors(path, value, schema) if value.is_a?(Numeric) append_size_bound_errors(path, value, schema) end |