-
Notifications
You must be signed in to change notification settings - Fork 21
Implement ApexDomain validator
#53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds 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)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this 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.
Related SER-1063
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.