These are chat archives for dry-rb/chat
Hi guys, I have some trouble using dry-validation. I am trying to ensure that some ids I receive from my API are actually valid records in my database. In my form I have this :
property sender_ids required(:sender_ids) do filled? & array? end rule(valid_senders: [:sender_ids]) do |sender_ids| Contact.exists?(id: value(:sender_ids)) end
But it raises the following error :
POST /letters with valid data returns the new letter Failure/Error: rule(valid_senders: [:sender_ids]) do |sender_ids| Contact.exists?(id: value(:sender_ids)) end NoMethodError: undefined method `with' for false:FalseClass # ./.gems/gems/dry-validation-0.10.4/lib/dry/validation/schema/value.rb:96:in `rule' # ./app/forms/letter/create_form.rb:31:in `block in <class:CreateForm>’
Do you have any idea ?
valid_contacts?function inside configure hook and call it from the