Skip to content

Add 'prefix_or_host' use case to IPv4/IPv6 validators - #3718

Merged
ipspace merged 2 commits into
devfrom
data-prefix-host
Jul 30, 2026
Merged

Add 'prefix_or_host' use case to IPv4/IPv6 validators#3718
ipspace merged 2 commits into
devfrom
data-prefix-host

Conversation

@ipspace

@ipspace ipspace commented Jul 30, 2026

Copy link
Copy Markdown
Owner

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_parse to support prefix_or_host, including correct expected-type handling for non-string inputs and clearer error messages.
  • Add a coverage error-case test for prefix_or_host and update expected logs.
  • Update developer documentation for IP validation use values.

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 thread netsim/data/types.py Outdated
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)' }
@ipspace ipspace mentioned this pull request Jul 30, 2026
@ipspace
ipspace merged commit ca90f89 into dev Jul 30, 2026
12 checks passed
@ipspace
ipspace deleted the data-prefix-host branch July 30, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants