module RequestParamsValidation::Params::Types::Validations
Public Instance Methods
valid_array?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 5 def valid_array?(value) value.is_a?(Array) end
valid_boolean?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 31 def valid_boolean?(value) (Params::BOOLEAN_TRUE_VALUES + Params::BOOLEAN_FALSE_VALUES).include?(value) end
valid_date?(value, format)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 35 def valid_date?(value, format) format = format || RequestParamsValidation.formats.date format ? Date.strptime(value, format) : Date.parse(value) true rescue ArgumentError, TypeError false end
valid_datetime?(value, format)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 45 def valid_datetime?(value, format) format = format || RequestParamsValidation.formats.datetime format ? DateTime.strptime(value, format) : DateTime.parse(value) true rescue ArgumentError, TypeError false end
valid_decimal?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 23 def valid_decimal?(value) !!(value.to_s =~ Params::DECIMAL_REGEXP) end
valid_email?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 27 def valid_email?(value) !!(value =~ Params::EMAIL_REGEXP) end
valid_hash?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 9 def valid_hash?(value) value.is_a?(Hash) || value.is_a?(ActionController::Parameters) rescue NameError # For older versions of Rails false end
valid_integer?(value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 19 def valid_integer?(value) !!(value.to_s =~ Params::INTEGER_REGEXP) end
valid_string?(_value)
click to toggle source
# File lib/request_params_validation/params/types/validations.rb, line 15 def valid_string?(_value) true end