option trace_transaction, true
BusyPeriods = Dry::Validation.Schema do
each do
schema do
required(:start_date).filled(:date?)
required(:end_date).filled(:date?)
required(:utilisation).filled(:int?)
rule(started_before_ended: [:start_date, :end_date]) do |start_date, end_date|
end_date.gt?(value(:start_date))
end
end
end
end
{ index => error_message }
but if the error comes from the rule
I will get just the error with out the index. Is that expected?
{0=>{:utilisation=>["must be an integer"]}}
{:started_before_ended=>["must be greater than 2018-03-21"]}
Types::Strict::String.constrained(filled: true).(nil)
Dry::Types::ConstraintError: nil violates constraints (type?(String, nil) AND filled?(nil) failed)
User.new(uid: 1, email: "foo", role: "admin").ref
=> nil
irb(main):017:0> Testing.new(ref: nil)
TypeError: nil (NilClass) has invalid type for :ref violates constraints (type?(Integer, nil) AND filled?(nil) failed)