Skip to content

Conversation

@hmacr
Copy link
Contributor

@hmacr hmacr commented Jan 23, 2026

Related SER-1063

Summary by CodeRabbit

  • New Features
    • Added apex domain validation to verify values are public root-level domains, rejecting subdomains and other variations.
  • Tests
    • Added unit tests covering valid apex domains and rejecting common subdomain/invalid variations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a new PHP validator class ApexDomain (namespace Utopia\Domains\Validator) that extends PublicDomain. getDescription() returns "Value must be a public apex domain". isValid($value) extracts host from a URL if needed, delegates to parent::isValid, constructs a Domain, and returns true only if the domain's apex equals the input. Adds PHPUnit test ApexDomainTest asserting the description and validating several apex and non-apex inputs (including URL forms).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately describes the main change: implementing a new ApexDomain validator class with corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@src/Domains/Validator/ApexDomain.php`:
- Around line 5-11: Remove the unused import and extra blank line: delete the
redundant "use Utopia\Domains\Validator\PublicDomain;" import and remove the
leading empty line inside the ApexDomain.php docblock above the class so the
file only imports "Utopia\Domains\Domain" and the docblock has a single opening
line before the description; update only the imports and the docblock whitespace
(no other logic changes).
- Around line 28-37: The current ApexDomain::isValid calls parent::isValid then
compares Domain->getApex() to the original $value, which fails for full URLs;
instead normalize the incoming $value to a canonical host before comparing.
Update ApexDomain::isValid to parse/normalize $value (e.g., create a Domain
instance from $value and extract its host or use parse_url to get host,
lowercasing and trimming) and then compare $domain->getApex() ===
$normalizedHost after parent::isValid succeeds.

In `@tests/Validator/ApexDomainTest.php`:
- Around line 24-33: The test file contains Pint whitespace violations
(no_whitespace_in_blank_line / single_blank_line) around the assertions using
$this->domain->getDescription() and multiple $this->domain->isValid(...) calls;
remove any trailing spaces on blank lines and ensure only a single blank line
between logical blocks so the test methods (references: $this->domain,
getDescription(), isValid()) comply with Pint's rules.

@hmacr hmacr merged commit 63fc5b9 into master Jan 23, 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.

3 participants