Skip to content
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

AtLeastOneOfValidator doesn't provide the full name of attribute in errors #1849

Closed
wwahammy opened this issue Dec 14, 2018 · 1 comment · Fixed by #1911
Closed

AtLeastOneOfValidator doesn't provide the full name of attribute in errors #1849

wwahammy opened this issue Dec 14, 2018 · 1 comment · Fixed by #1911
Labels

Comments

@wwahammy
Copy link

Currently, AtLeastOneOfValidator only provides the minimal attribute name on a validation error. This is different from other validators where we use the full name. As an example, let's consider the following parameters:

requires :address, type: Hash do
  requires :needed_attr
  optional :attr_1
  optional :attr_2
  at_least_one_of :attr1, :attr2
end

If address[needed_attr] isn't set, the hash key for that attribute's errors is address[needed_attr]. On the other hand, the hash key for errors on address[attr1] and address[attr2] is ['attr1', 'attr2']. This is inconsistent. Is this expected behavior? If not, I'd be willing to submit a pull request to fix it.

@dblock
Copy link
Member

dblock commented Dec 16, 2018

I think this is a bug, PR appreciated, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants