Module: ParamsValidator::Validator::Base

Included in:
TypeArray, TypeFloat, TypeHash, TypeInteger, TypeString
Defined in:
lib/params_validator/validator/type.rb

Class Method Summary collapse

Class Method Details

.error_messageObject



12
13
14
# File 'lib/params_validator/validator/type.rb', line 12

def self.error_message
  "is not of type #{@type_name.to_s.downcase}"
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/params_validator/validator/type.rb', line 16

def self.valid?(value)
  return true unless Presence.valid?(value)
  return !!@block.call(value) rescue false
end