Class: StrongerParameters::DateTimeConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- StrongerParameters::DateTimeConstraint
- Defined in:
- lib/stronger_parameters/constraints/date_time_constraint.rb
Instance Method Summary collapse
Methods inherited from Constraint
#&, #==, #required, #required?, #|
Instance Method Details
#value(v) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/stronger_parameters/constraints/date_time_constraint.rb', line 7 def value(v) return v if v.is_a?(DateTime) begin DateTime.parse v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be a datetime") end end |