Document open ranges as a lighter alternative to a numericality validator#2831
Merged
Merged
Conversation
dblock
force-pushed
the
support-open-ranges-values
branch
from
July 27, 2026 00:23
27b1b77 to
337239a
Compare
Danger ReportNo issues found. |
dblock
force-pushed
the
support-open-ranges-values
branch
4 times, most recently
from
July 27, 2026 00:34
2f3191e to
929934b
Compare
…idator Instead of adding a new numericality validator (ruby-grape#2822), extend test coverage and documentation for the existing :values option, which already supports open (beginless/endless) Ranges via Range#include?. This covers the same common cases (positive numbers, percentages, exact values, and array element-wise checks) without a new validator. Ref: ruby-grape#2822 (comment) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dblock
force-pushed
the
support-open-ranges-values
branch
from
July 27, 2026 00:35
929934b to
b869c9a
Compare
ericproulx
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#2822 proposed a new
numericalityvalidator for bounding numeric parameters (greater_than,less_than,equal_to, etc.). As discussed on that PR, Grape's existing:valuesoption already supportsRange, including open (beginless/endless) ranges, since it validates withRange#include?. This covers the same common use cases without adding a new validator:This PR does not change any validator code (open ranges already work end-to-end). It:
/beginlessrange test alongside the existing/endlessone invalues_validator_spec.rb.numericality_validator_spec.rb(greater_than, greater_than_or_equal_to/less_than_or_equal_to range, equal_to, array element-wise checking, integer-only viatype:) asvalues:+ range equivalents.:valuessection.Test plan
bundle exec rspec spec/grape/validations/validators/values_validator_spec.rb(73 examples, 0 failures)bundle exec rake(full suite + RuboCop) passes locally