class StrongerParameters::RegexpConstraint
Attributes
regexp[R]
Public Class Methods
new(regexp)
click to toggle source
# File lib/stronger_parameters/constraints/regexp_constraint.rb, line 8 def initialize(regexp) @regexp = regexp @string = StringConstraint.new end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
StrongerParameters::Constraint#==
# File lib/stronger_parameters/constraints/regexp_constraint.rb, line 24 def ==(other) super && regexp == other.regexp end
value(v)
click to toggle source
# File lib/stronger_parameters/constraints/regexp_constraint.rb, line 13 def value(v) v = @string.value(v) return v if v.is_a?(InvalidValue) if v =~ regexp v else InvalidValue.new(v, "must match #{regexp.source}") end end