Add tolerance percentage to validate #1813
Merged
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 ability to validate based on a percentage tolerance either side of the specified value (useful for BGP prefixes). I was trying to keep it as close to existing operators (
"<d"
,">d"
,"d<->d"
), in the end came up with"t%d"
. The logic behind it is that a tolerance of "t percent of d" is allowed either side of the value of d. For example"10%100"
would be 10% of 100, so a value between 90 and 110 is accepted. I didnt really want to use a % sign but couldn't think of a better way to represent this. Have done tests and docs that I could find, let me know if need anything else.