Class: Castkit::Validators::NumericValidator
- Defined in:
- lib/castkit/validators/numeric_validator.rb
Overview
Validates that a numeric value falls within the allowed range.
Supports ‘:min` and `:max` options to enforce bounds.
Direct Known Subclasses
Instance Method Summary collapse
-
#call(value, options:, context:) ⇒ void
Validates the numeric value.
Methods inherited from Base
Instance Method Details
#call(value, options:, context:) ⇒ void
This method returns an undefined value.
Validates the numeric value.
18 19 20 21 22 23 24 25 26 |
# File 'lib/castkit/validators/numeric_validator.rb', line 18 def call(value, options:, context:) if [:min] && value < [:min] raise Castkit::AttributeError, "#{context} must be >= #{[:min]}" end return unless [:max] && value > [:max] raise Castkit::AttributeError, "#{context} must be <= #{[:max]}" end |