Add 'prefix_or_host' use case to IPv4/IPv6 validators - #3718
Merged
Conversation
The ACLs accept either a prefix or an IP address (= host), but not the additional interface values (true/false/int). No existing 'use' value matched the requirements.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new use: prefix_or_host mode to the shared IPv4/IPv6 address validators so attributes can accept either an IP prefix (with host bits zero) or a host IP address (without prefix), matching ACL requirements.
Changes:
- Extend
common_addr_parseto supportprefix_or_host, including correct expected-type handling for non-string inputs and clearer error messages. - Add a coverage error-case test for
prefix_or_hostand update expected logs. - Update developer documentation for IP validation
usevalues.
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/errors/ia-ospf-nodes.log | Updates expected error output formatting/line numbering impacted by validator messaging. |
| tests/coverage/errors/attr-ip-prefix-host.yml | Adds a new coverage test case for the prefix_or_host validator mode. |
| tests/coverage/errors/attr-ip-prefix-host.log | Captures expected validation failures for the new coverage test. |
| netsim/data/types.py | Implements prefix_or_host behavior in the common IPv4/IPv6 validation logic and adjusts related error/type reporting. |
| docs/dev/validation-ip.txt | Documents the new prefix_or_host mode and clarifies existing use semantics. |
Comment on lines
+775
to
+777
| if isinstance(value,bool): # bool values are valid only on interfaces and subnets | ||
| if use not in ('interface','subnet_prefix'): | ||
| return { '_value' : f'an {af} address (boolean value is valid only on an interface)' } | ||
| return { '_value' : f'{exp_type} (boolean value is valid only on an interface)' } |
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.
The ACLs accept either a prefix or an IP address (= host), but not the additional interface values (true/false/int). No existing 'use' value matched the requirements.