Class: WeakParameters::IntegerValidator

Inherits:
BaseValidator show all
Defined in:
lib/weak_parameters/integer_validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#key, #options, #params

Instance Method Summary collapse

Methods inherited from BaseValidator

#initialize, #required?, #type, #validate

Constructor Details

This class inherits a constructor from WeakParameters::BaseValidator

Instance Method Details

#error_messageObject



7
8
9
# File 'lib/weak_parameters/integer_validator.rb', line 7

def error_message
  "params[#{key.inspect}] must be an Integer"
end

#valid_type?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/weak_parameters/integer_validator.rb', line 3

def valid_type?
  /\A-?\d+\z/ === value.to_s
end