We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'd like to use dry-validation to ensure a particular class attributes is greater than an other.
For exemple:
Dry::Validation.Schema do required(:contribution).filled? required(:payment_amount).filled(:int?) rule(payment_amount_is_greater_than_contribution_amount: [:contribution, :payment_amount]) do |contribution, payment_amount| payment_amount.gt?(value(:contribution).amount) end end
But I got the error ArgumentError: +amount+ is not a valid predicate name
ArgumentError: +amount+ is not a valid predicate name
My second use case will be an external API call as a validator:
Dry::Validation.Schema do required(:user).filled? rule(user_has_remote_account: [:user]) do |user| value(:user).remote_account? end end
I think I can use a custom predicate for that, but I'm not sure it's the right way to do it.
Any chance someone can help me ? :)
The text was updated successfully, but these errors were encountered:
rule uses internal DSL so you can't access normal values there. You can use validate instead:
rule
validate
validate(user_has_remote_account: [:user]) do |user| user.remote_account? end
Sorry, something went wrong.
Thanks for your quick answer ! Unfortunately, this method is not documented on your website :(
No branches or pull requests
I'd like to use dry-validation to ensure a particular class attributes is greater than an other.
For exemple:
But I got the error
ArgumentError: +amount+ is not a valid predicate name
My second use case will be an external API call as a validator:
I think I can use a custom predicate for that, but I'm not sure it's the right way to do it.
Any chance someone can help me ? :)
The text was updated successfully, but these errors were encountered: