I want to allow date formatted string with dry-validation gem, but I can't.
class NewUserContract < Dry::Validation::Contract
params do
optional(:date).filled(:date)
end
end
contract = NewUserContract.new
contract.call(date: Date.today)
#=> #<Dry::Validation::Result{:date=>Tue, 14 Jan 2020} errors={}>
# I want to allow date formatted string
contract.call(date: '2020-01-20')
#=> #<Dry::Validation::Result{:date=>"2020-01-20"} errors={:date=>["must be a date"]}>
Date formatted string was allowed until 0.13, but it seems prohibited since 1.0. Now I'm trying to upgrade the dry-validation gem in my Rails app.
EDIT
I am not sure why, but the code above is working now. Maybe caching issue? (I remember I ran bin/rake tmp:cache:clear
, though) Please ignore this question.