-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
each + macro without args broken #538
Comments
it works for me 🤔 |
# frozen_string_literal: true
require 'dry/validation'
class MyContract < Dry::Validation::Contract
params do
required(:num).filled(:integer)
end
register_macro(:even?) do
key.failure('must be even') unless value.even?
end
rule(:num).validate(:even?)
end
contract = MyContract.new
puts contract.call(num: 3).errors.inspect
# #<Dry::Validation::MessageSet messages=[#<Dry::Validation::Message text="must be even" path=[:num] meta={}>] options={}>
puts contract.call(num: 4).errors.inspect
# #<Dry::Validation::MessageSet messages=[] options={}> I can't reproduce this either. |
# frozen_string_literal: true
require 'dry/validation'
class MyContract < Dry::Validation::Contract
params do
required(:nums).filled(:array)
end
register_macro(:even?) do
key.failure('must be even') unless value.even?
end
rule(:nums).each(:even?)
end
contract = MyContract.new
puts contract.call(nums: [3]).errors.inspect
undefined method `flatten' for :broker_schema?:Symbol (NoMethodError) |
oh doooh this one is about |
same for: # frozen_string_literal: true
require 'dry/validation'
class MyContract < Dry::Validation::Contract
params do
required(:nums).value(:array, :filled?)
end
register_macro(:even?) do
key.failure('must be even') unless value.even?
end
rule(:nums).each(:even?)
end
contract = MyContract.new
puts contract.call(nums: [3]).errors.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
won't work:
works:
The text was updated successfully, but these errors were encountered: