Class: RailsParam::Validator::In

Inherits:
RailsParam::Validator show all
Defined in:
lib/rails_param/validator/in.rb

Constant Summary

Constants inherited from RailsParam::Validator

VALIDATABLE_OPTIONS

Instance Attribute Summary

Attributes inherited from RailsParam::Validator

#parameter

Instance Method Summary collapse

Methods inherited from RailsParam::Validator

#initialize, #valid!, #validate!

Constructor Details

This class inherits a constructor from RailsParam::Validator

Instance Method Details

#valid_value?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
# File 'lib/rails_param/validator/in.rb', line 4

def valid_value?
  value.nil? || case options[:in]
                when Range
                  options[:in].include?(value)
                else
                  Array(options[:in]).include?(value)
                end
end