Allow validates_length_of to work on association - Fix #1007
if the length check is on an association then create an array to assign to the association instead of a string
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.
It would be great to have this feature in the main gem!
@mcmire is there anything pending for this PR?
@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+ qualifieris_at_least - Validation option
maximum+ qualifieris_at_most - Validation option
is+ qualifieris_equal_to -
allow_nil -
allow_blank
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, .
@KapilSachdev No worries, I should have said something initially when adding that tag. Thank you, that would be much appreciated!
Closing this PR as this was implemented on #1569.