feat: add limits to input attributes#4063
Open
kdrienCG wants to merge 17 commits into
Open
Conversation
Will not compile due to std::optional instantiation (used by m_minValue and m_maxVavlue) for abstract types like PartitionBase
setLimits() has the same capabilities and should be the only one kept.
dkachuma
approved these changes
May 20, 2026
Contributor
dkachuma
left a comment
There was a problem hiding this comment.
I really like this idea. It will simplify greatly some of the boiler plate validation code.
Will this work for lists of numbers?
| return; | ||
| } | ||
|
|
||
| string const msg = GEOS_FMT( "Value {} for attribute '{}' is outside the allowed range.", |
Contributor
There was a problem hiding this comment.
I would add the range to the message.
Also will this show the full context, not just the field name? Should we use getDataContext()?
dkachuma
approved these changes
May 20, 2026
| std::enable_if_t< is_limitable_v< U >, Wrapper< T > & > | ||
| setLimits( std::optional< Bound< T > > min, | ||
| std::optional< Bound< T > > max, | ||
| LimitsMode mode = LimitsMode::Warning ) |
Contributor
There was a problem hiding this comment.
Suggested change
| LimitsMode mode = LimitsMode::Warning ) | |
| LimitsMode mode = LimitsMode::Error ) |
I think error is a better default here (most cases would be errors).
This part may be refactored, to build the range string somewhere else
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.
This PR adds the possibility to specify a min and/or a max value to
Wrappers attributes.This will serve as a documentation for values, but also prevents users from making typos that could lead to wrong results, taking time to find (if noticed).
The limits come with 3 modes:
The mode can be set when specifying the limit, using this syntax:
... or it will default to
Warningif unset.Limits also support inclusive and exclusive bounds:
Not using
inclusive(...)orexclusive(...)will default to an inclusive limit.Some examples: