These are chat archives for dry-rb/chat

Oct 2016
Jean-Michel Garnier
Oct 12 2016 08:55
Thanks @nepalez Things move very fast in dry-rb word, thank you for the notification :)
Tom Willis
Oct 12 2016 12:54

Hey all, was upgrading to the 0.10 series from the 0.9 series and I'm getting errors in the schemas that use rules with custom predicates...

"ArgumentError: unique_npi_number? predicate arity is invalid"

    configure do
      def unique_npi_number?(id, org_uid, npi_number)
        return true if npi_number.nil?
        existing_provider = Provider.find(org_uid: org_uid, npi_number: npi_number)
        if existing_provider && existing_provider[:provider_uid] != id


    rule(unique_npi_number: [:id, :org_uid, :npi_number]) do |id, org_uid, npi_number|
      npi_number.unique_npi_number?(npi_number, org_uid, id)

was working just fine on the 0.9 series

Christopher Dennl-Ortega Arrieta
Oct 12 2016 13:08
@twillis you can now define arbitrary validation rules, check the changelog on 0.10. some stuff changed
@twillis and you put in 4 arguments to a predicate which takes 3
@twillis you can omit the npi_number argument at the function call
npi_number.unique_npi_number?(org_uid, id) should do the trick
Tom Willis
Oct 12 2016 13:14
ah ok I'll check the change log, i'd rather re-write the stuff if it's a cleaner syntax than the above. thanks so much @cdennl