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

Allow validates_length_of to work on association - Fix #1007 #1124

Conversation

prashantjois
Copy link

if the length check is on an association then create an array to assign to the association instead of a string

@prashantjois
Copy link
Author

This enhancement works but I'm struggling to test it. Would love some guidance on creating a test model with a has_many and has_many through: ... association.

@prashantjois prashantjois changed the title Allow validates_length_of to work on association Allow validates_length_of to work on association (https://github.com/thoughtbot/shoulda-matchers/issues/1007) Sep 3, 2018
@guialbuk guialbuk changed the title Allow validates_length_of to work on association (https://github.com/thoughtbot/shoulda-matchers/issues/1007) Allow validates_length_of to work on association - Fixes #1007 Sep 4, 2018
@guialbuk guialbuk changed the title Allow validates_length_of to work on association - Fixes #1007 Allow validates_length_of to work on association - Fix #1007 Sep 4, 2018
@mcmire mcmire added this to the v4.next milestone Feb 18, 2019
@StragaSevera
Copy link

It would be great to have this feature in the main gem!

@KapilSachdev
Copy link
Collaborator

@mcmire is there anything pending for this PR?

@mcmire
Copy link
Collaborator

mcmire commented Sep 8, 2020

@KapilSachdev Yes. In order to merge this addition, there need to be tests. Essentially, most of the scenarios represented within validate_length_of_spec, including most of the qualifier tests, need to be updated to also account for associations. This includes:

  • Validation option minimum + qualifier is_at_least
  • Validation option maximum + qualifier is_at_most
  • Validation option is + qualifier is_equal_to
  • allow_nil
  • allow_blank

@KapilSachdev
Copy link
Collaborator

My bad, i missed the PR: Needs Tests label.
As the OP hasn't responded and in case anyone else does not wants to work, I will move this PR forward asap, .

@mcmire
Copy link
Collaborator

mcmire commented Sep 8, 2020

@KapilSachdev No worries, I should have said something initially when adding that tag. Thank you, that would be much appreciated!

@matsales28
Copy link
Member

Closing this PR as this was implemented on #1569.

@matsales28 matsales28 closed this Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants