Class: StrongerParameters::HexConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/stronger_parameters/constraints/hex_constraint.rb

Instance Method Summary collapse

Methods inherited from Constraint

#&, #==, #required, #required?, #|

Instance Method Details

#value(v) ⇒ Object



6
7
8
9
10
# File 'lib/stronger_parameters/constraints/hex_constraint.rb', line 6

def value(v)
  return v if v =~ /\A[a-f0-9]+\z/i

  InvalidValue.new(v, 'must be a hexadecimal string')
end