class Parametron::ParamsValidator::GenericParameter
Public Class Methods
new(name, default, validator, as, cast)
click to toggle source
Calls superclass method
# File lib/parametron/params_validator.rb, line 95 def initialize(name, default, validator, as, cast) super unless as.nil? || String === as || Symbol === as fail ArgumentError, 'Parameter :as should be either String or Symbol!' end end
Public Instance Methods
valid?(value)
click to toggle source
# File lib/parametron/params_validator.rb, line 102 def valid?(value) case self.validator when Regexp then value && !!self.validator.match(value.to_s) when Proc then value && !!self.validator.call(value) else true end end