You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
validate_inclusion_of accepts a message option, inside which you are able to specify the value that was passed to the field for validation. It looks like:
with_message('the value: %{value} is not inside the acceptable list')
Shoulda-matchers does not seem to respect the interpolation of this custom value. It is shown in the method documentation here:
When I try this locally, my code looks like this:
validates_inclusion_of :rating, in: 1..5, allow_nil: true, message: 'the value: %{value} is not between 1 and 5'
And the error message I receive is:
Expected Survey to validate that :rating lies inside the
range ‹1› to ‹5› as long as it is not nil, producing a custom validation
error on failure, but this could not be proved.
After setting :rating to ‹0›, the matcher expected the
Survey to be invalid and to produce the validation error "the value:
%{value} is not between 1 and 5" on :rating. The record was
indeed invalid, but it produced these validation errors instead:
* rating: ["the value: 0 is not between 1 and 5"]
I believe this is an error in the shoulda-matchers code, as it is not interpolating the value correctly with the error message.
The text was updated successfully, but these errors were encountered:
validate_inclusion_of
accepts amessage
option, inside which you are able to specify the value that was passed to the field for validation. It looks like:Shoulda-matchers does not seem to respect the interpolation of this custom value. It is shown in the method documentation here:
When I try this locally, my code looks like this:
And the error message I receive is:
I believe this is an error in the shoulda-matchers code, as it is not interpolating the value correctly with the error message.
The text was updated successfully, but these errors were encountered: