Module: CMDx::Validators::Exclusion
Overview
Validates that a value is not included in a specified set or range
This validator ensures that the given value is excluded from a collection of forbidden values or falls outside a specified range. It supports both discrete value lists and range-based exclusions.
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Validates that a value is excluded from the specified options.
Instance Method Details
#call(value, options = {}) ⇒ Object
Validates that a value is excluded from the specified options
37 38 39 40 41 42 43 44 45 |
# File 'lib/cmdx/validators/exclusion.rb', line 37 def call(value, = {}) values = [:in] || [:within] if values.is_a?(Range) raise_within_validation_error!(values.begin, values.end, ) if values.cover?(value) elsif Array(values).any? { |v| v === value } raise_of_validation_error!(values, ) end end |