Class: PoroValidator::Validators::RangeArrayValidator

Inherits:
BaseClass
  • Object
show all
Defined in:
lib/poro_validator/validators/range_array_validator.rb

Overview

Since:

  • 0.0.1

Direct Known Subclasses

ExclusionValidator, InclusionValidator

Instance Attribute Summary

Attributes inherited from BaseClass

#attribute

Instance Method Summary collapse

Methods inherited from BaseClass

#__validate__, #context, #errors, #initialize, #nested?, #options, #validate, #value

Constructor Details

This class inherits a constructor from PoroValidator::Validators::BaseClass

Instance Method Details

#covered?(range, value) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.1



9
10
11
12
# File 'lib/poro_validator/validators/range_array_validator.rb', line 9

def covered?(range, value)
  return unless range.respond_to?(:cover?)
  range.cover?(value)
end

#included?(array, value) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.1



14
15
16
17
# File 'lib/poro_validator/validators/range_array_validator.rb', line 14

def included?(array, value)
  return unless array.respond_to?(:include?)
  array.include?(value)
end

#validate_option(option) ⇒ Object

Since:

  • 0.0.1



5
6
7
# File 'lib/poro_validator/validators/range_array_validator.rb', line 5

def validate_option(option)
  !option.nil? && (option.is_a?(::Range) || option.is_a?(::Array))
end