Skip to content

feat: add configurable URL validation options#233

Draft
nieomylnieja wants to merge 4 commits into
mainfrom
add-options-to-url-rule
Draft

feat: add configurable URL validation options#233
nieomylnieja wants to merge 4 commits into
mainfrom
add-options-to-url-rule

Conversation

@nieomylnieja

@nieomylnieja nieomylnieja commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Currently URL validation only checks for the most common errors, but often times there are other common checks users are forced to implement themselves. I think it would be worthwhile to extend the current rules.URL signature with opt-in options, which would verify additional properties of the URL.

Summary

Support scheme, host, user info, and hostname allow/deny checks in the URL rule. Add targeted error messages and tests to cover the new validation behavior.

Release Notes

Added configurable rules.URL validation options for enforcing allowed schemes, required hosts, disallowed user info, and hostname allow/deny lists. URL option failures now use built-in message templates so applications can customize or translate them consistently.

Support scheme, host, user info, and hostname allow/deny checks in the URL rule.
Add targeted error messages and tests to cover the new validation behavior.
@n9-machine-user n9-machine-user added enhancement New feature or request go Pull requests that update Go code minor New functionality with at most minor brekaing changes labels Jun 1, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Test coverage changes:

Package Before After Diff
github.com/nobl9/govy/cmd/govy 0% 0% ✔️
github.com/nobl9/govy/internal 73% 73% ✔️
github.com/nobl9/govy/internal/collections 100% 100% ✔️
github.com/nobl9/govy/internal/inferpath 76% 76% ✔️
github.com/nobl9/govy/internal/messagetemplates 89% 89% ✔️
github.com/nobl9/govy/internal/stringconvert 86% 86% ✔️
github.com/nobl9/govy/internal/typeinfo 94% 94% ✔️
github.com/nobl9/govy/pkg/govy 93% 93% ✔️
github.com/nobl9/govy/pkg/govytest 100% 100% ✔️
github.com/nobl9/govy/pkg/jsonpath 85% 85% ✔️
github.com/nobl9/govy/pkg/rules 98% 98% ✔️

Reuse the variadic slice in `URLSchemes` instead of copying it.
This removes an unnecessary allocation while preserving behavior.
Validate each URL option directly against the parsed URL instead of building
an intermediate options struct, reducing indirection in rule evaluation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update Go code minor New functionality with at most minor brekaing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants