codegram / date_validator

A simple, ORM agnostic, Ruby >=2.2 compatible date validator for Rails, based on ActiveModel.
http://thoughts.codegram.com/date-validation-with-rails-3
MIT License
495 stars 82 forks source link

Proc in error details #90

Closed fdutey closed 2 years ago

fdutey commented 2 years ago

🐞 Bug Report

When you set a value for after (or any other comparison option) with a Proc object, the value appearing in error details is an inspect of the Proc itself instead of being the result of Proc.call

Steps to reproduce

How can we reproduce the bug? Example:

class Model
  validates :date_field, { after: Proc.new { Time.now } }
end

m = Model.new
m.valid?
puts m.errors.details[:date_field}

# => { ..., after: #<Proc:0x0000... > }

Current Behavior

Which broken behavior are you experiencing?

String dump of Proc value from options

Expected behavior

We should have the actual value returned by Proc.call

Input Code

see above

Environment

Env doesnt matter for this issue

Possible Solution

add option_value in ***options.merge() in validations/date_validator.rb