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)
Hi, i have question about dynamic arguments in dry-v schema
I try to define schema
CreateSchema = Dry::Validation.Form do
configure do
option :min_time
def time_range
min_time...Time.current
end
end
required(:start_at).filled(:time?, included_in?: time_range)
end
but i have the error when use this schema
CreateSchema.with(min_time: 10.minutes.ago).call(params)
Failure/Error: min_time...Time.current
ArgumentError:
bad value for range
I think this error raised when schema compiled and option min_time at thid moment is nil. It’s right way to define schema like this with dynamic agruments?