Skip to content

Improve Url validator to be more strict#1662

Merged
alganet merged 1 commit into
Respect:mainfrom
alganet:url-improvements
Feb 2, 2026
Merged

Improve Url validator to be more strict#1662
alganet merged 1 commit into
Respect:mainfrom
alganet:url-improvements

Conversation

@alganet

@alganet alganet commented Jan 31, 2026

Copy link
Copy Markdown
Member

Previously, the URL validator accepted all kinds of URLs.

Combining it with other validators like Domain and Ip manually is clumbersome, since the rules are extensive and require small tweaks such as understanding bracketed IP addresses.

This change makes that composition built-in. The validator still uses the FILTER_VALIDATE_URL from PHP, but now it also goes deeper and validate portions of the URL that other validators support.

Changes to Call were made so that it can be serialized under certain circumstances (when invoking a static method call), making it more flexible.

A static internal method helper for trimming the IP was added to the Url validator class and marked as internal, as it cannot be both private, serializable and accessible to the Call instance all at the same time. The @internal annotation should advise users that it's not a public API according to phpdoc conventions.

@codecov

codecov Bot commented Jan 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.53%. Comparing base (ce527e2) to head (f773c25).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1662   +/-   ##
=========================================
  Coverage     99.53%   99.53%           
- Complexity      920      923    +3     
=========================================
  Files           190      190           
  Lines          2148     2171   +23     
=========================================
+ Hits           2138     2161   +23     
  Misses           10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alganet alganet marked this pull request as ready for review January 31, 2026 20:14

@henriquemoody henriquemoody left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love the changes in the URL! It's awesome to have such a good case using our own validators.

The changes you made on Call(), though, need to be reverted because they will introduce unwanted behavior

Comment thread src/Validators/Call.php Outdated
@alganet alganet force-pushed the url-improvements branch 2 times, most recently from c6efe9d to 929c89b Compare February 1, 2026 23:13
Previously, the URL validator accepted all kinds of URLs.

Combining it with other validators like `Domain` and `Ip` manually
is clumbersome, since the rules are extensive and require small
tweaks such as understanding bracketed IP addresses.

This change makes that composition built-in. The validator still
uses the FILTER_VALIDATE_URL from PHP, but now it also goes deeper
and validate portions of the URL that other validators support.

Changes to `Call` were made so that it can be serialized under
certain circumstances (when invoking a static method call), making
it more flexible.

A static internal method helper for trimming the IP was added to
the Url validator class and marked as internal, as it cannot be
both private, serializable and accessible to the `Call` instance
all at the same time. The `@internal` annotation should advise
users that it's not a public API according to phpdoc conventions.
@alganet alganet merged commit a64e331 into Respect:main Feb 2, 2026
7 checks passed
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