Repository navigation
chore: absorb validators into packages/validators - #13897
Conversation
Test base server
Feat base servers
Feat: Rules for Multiple validator
# Conflicts: # composer.lock
Added AnyOf Validator
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
docs: enforce documentation style with Vale
docs: centralize CODE_OF_CONDUCT and CONTRIBUTING at the monorepo root
feat(validators): add JSON object and array shape validators
Add Phone validator
feat(validators): add Identifier validator
…lank validators: require non-blank text values
feat(validators): add FCM service account validator
fix(validators): Assoc declares an object, not an array
chore: stop committing package lock files
# Conflicts: # composer.json # composer.lock
|
| $this->assertSame( | ||
| "FCM service account JSON must include a non-empty '{$field}' field, which {$purpose}.", | ||
| $validator->getDescription(), |
There was a problem hiding this comment.
Tests mirror private error strings. These assertions repeat the validator’s private field-purpose text and error-message template; the other FCM cases repeat more error strings. Rewording an error without changing which credentials are accepted would fail the tests. The repository requires tests of observable behavior, not assertions that mirror source code or configuration. This requirement must be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/tests/JSON/FCMTest.php
Line: 63-65
Comment:
**Tests mirror private error strings.** These assertions repeat the validator’s private field-purpose text and error-message template; the other FCM cases repeat more error strings. Rewording an error without changing which credentials are accepted would fail the tests. The repository requires tests of observable behavior, not assertions that mirror source code or configuration. This requirement must be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| composer test | ||
| ``` | ||
|
|
||
| This project is released under the [MIT License](LICENSE.md). |
There was a problem hiding this comment.
License link is broken. The imported license is named
LICENSE, but this link points to LICENSE.md, so readers following it reach a missing page.
| This project is released under the [MIT License](LICENSE.md). | |
| This project is released under the [MIT License](LICENSE). |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/README.md
Line: 87
Comment:
**License link is broken.** The imported license is named `LICENSE`, but this link points to `LICENSE.md`, so readers following it reach a missing page.
```suggestion
This project is released under the [MIT License](LICENSE).
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| Run the static analysis and test suites from the project root: | ||
|
|
||
| ```bash | ||
| composer check | ||
| composer test | ||
| ``` |
There was a problem hiding this comment.
Development commands check the root.
composer check and composer test run the root project’s checks and tests, not the validators package checks described here. The root PHPStan paths omit packages/validators, so a contributor following these instructions can miss package errors. Document the package-specific commands instead.
| Run the static analysis and test suites from the project root: | |
| ```bash | |
| composer check | |
| composer test | |
| ``` | |
| Run the validators checks and tests from the project root: | |
| ```bash | |
| bin/monorepo check validators | |
| bin/monorepo test validators |
<details><summary>Prompt To Fix With AI</summary>
`````markdown
This is a comment left during a code review.
Path: packages/validators/README.md
Line: 80-85
Comment:
**Development commands check the root.** `composer check` and `composer test` run the root project’s checks and tests, not the validators package checks described here. The root PHPStan paths omit `packages/validators`, so a contributor following these instructions can miss package errors. Document the package-specific commands instead.
```suggestion
Run the validators checks and tests from the project root:
```bash
bin/monorepo check validators
bin/monorepo test validators
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
# Conflicts: # composer.lock
| #[\Override] | ||
| public function isValid(mixed $value): bool | ||
| { | ||
| return parent::isValid($value) && preg_match('/^[A-Za-z_]\w*$/D', (string) $value) === 1; |
There was a problem hiding this comment.
Regular expression violates repository guidance. This identifier check adds
preg_match() without explaining why string or character functions cannot be used. The repository instruction says not to add regular expressions unless alternatives cannot work and the reason is explained in the PR. The same pattern appears in Phone and HexColor, among other imported validators. This requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/src/Validator/Identifier.php
Line: 38
Comment:
**Regular expression violates repository guidance.** This identifier check adds `preg_match()` without explaining why string or character functions cannot be used. The repository instruction says not to add regular expressions unless alternatives cannot work and the reason is explained in the PR. The same pattern appears in `Phone` and `HexColor`, among other imported validators. This requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
# Conflicts: # composer.lock # rfc/monorepo.md
# Conflicts: # composer.lock
| { | ||
| $arrayList = new ArrayList(new Integer()); | ||
| $this->assertFalse($arrayList->isValid(['text'])); | ||
| $this->assertSame('Value must a valid array and Value must be a valid signed 32-bit integer between -2,147,483,648 and 2,147,483,647', $arrayList->getDescription()); |
There was a problem hiding this comment.
Tests mirror description wording. These tests hard-code complete descriptions, including the nested validator’s wording. The JSON shape tests do the same. This violates the repository directive to test observable behavior rather than mirror source text: a wording change would fail the suite even if the validators accepted and rejected exactly the same values. This requirement must be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/tests/ArrayListTest.php
Line: 19
Comment:
**Tests mirror description wording.** These tests hard-code complete descriptions, including the nested validator’s wording. The JSON shape tests do the same. This violates the repository directive to test observable behavior rather than mirror source text: a wording change would fail the suite even if the validators accepted and rejected exactly the same values. This requirement must be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
This moves
utopia-php/validatorsintopackages/validators, so Appwrite loads it directly. It's the first package of wave 1 in #13828 and follows the playbook inrfc/monorepo.md. It comes in three commits, plus a merge ofmain:Add 'packages/validators/' from commit 'f0a08bd8…': subtree import from the mirror with full history. The mirror head is the1.0.1commit Appwrite already locks, so the code Appwrite runs doesn't change.chore(validators): mirror plumbing:mirror.ymlnow points at this repository'smirror-redirect, and the README banner points here instead ofutopia-php/monorepo. The package had no banned files or hoisted QA tooling to strip.refactor: load validators from packages/:Adds the root autoload and
replaceentries, drops theutopia-php/validators: ^1.0require line, and removes the package from the lock. Ten still-vendored packages requireutopia-php/validators, andreplacenow satisfies them.Bare
Utopia\prefix. The package keeps declaringUtopia\→src/, becauseUtopia\Validator(the base class) andUtopia\PHPStan\DisallowAssertEqualsExtensionlive at the namespace root. Renaming those is step B (phase 6), not this PR. It's the first absorbed package with the bare prefix, sobin/monorepolearns about it:BARElist (validators => Validator) names the packages allowed to declareUtopia\, plus the segment their tests use.validateacceptsUtopia\→src/for those packages only.autoloadwrites the bare prefix as a directory list ("Utopia\\": ["packages/validators/src"]), probed last. It also no longer copies a list-valued entry through untouched, which would have duplicatedpackages/paths on every regeneration.validatenow fails on any class underpackages/that more than one PSR-4 directory can load. It checks against the root map and, whenvendor/is installed, against every vendored package. That's where the bare prefix is still shared withhttp,consoleanddi. The RFC already promised this check, but it wasn't implemented. Beforecomposer update --lockremoved the vendored copy, the check flagged all 31 validators classes. It's clean now.Utopia\Validator,Utopia\Validator\*andUtopia\PHPStan\*resolve topackages/validators/src, whileUtopia\Http\*,Utopia\ConsoleandUtopia\DI\*still resolve tovendor/. Composer's generated map listspackages/validators/srcfirst underUtopia\, ahead of the three vendored directories.Step A of the standard shape:
src/is already flat under the bare prefix (src/Validator.php,src/Validator/*,src/PHPStan/*), so nothing moves.tests/Validator/*moves up totests/. Tests move fromUtopia\Validator(the same namespace as the classes under test) toUtopia\Validator\TestsandUtopia\Validator\Tests\JSON, with explicit imports and a matchingautoload-deventry.LICENSE.mdbecomesLICENSE, andphpunit.xmlandrector.phpmatch the sibling packages. Rector leavessrcalone and removed one emptysetUp()from a test. The only changes tosrcagainst the imported1.0.1are Pint's (empty constructor bodies andfn (spacing).phpstan.neonused to include../../phpstan.neon, whichvalidaterejects, so it's now standalone at level max oversrcandtests. It keeps registering the package's ownDisallowAssertEqualsExtension. Aphpstan-baseline.neonholds 75 findings, because the monorepo analysed this package at level 5:src: unvaluedarrayparameters and casts frommixed, mostly inGlobstar,Domain,URL,ContainsandWhiteList.AssocTestandURLTest.The RFC's phase 8 burn-down list now includes them.
rfc/monorepo.mddocumentsBAREnext to the root autoload description.There's nothing to hoist, since the package requires only PHP.
main(with thelocaleabsorb, #13888) is merged in, not rebased, so the subtree history is intact.composer.jsonandcomposer.lockwere resolved by takingmain's and re-runningbin/monorepo autoloadandcomposer update --lock.Validation
bin/monorepo validate: all packages valid, including the new duplicate-class check against the installedvendor/bin/monorepo check validators: Rector, Pint and PHPStan level max (with baseline) passbin/monorepo test validators: 185 tests / 1,084 assertions (there's no e2e tier)vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Validator\\Tests': the same 185 tests / 1,084 assertions pass under the root autoloadervendor/bin/phpunit tests/uniton the host: 1,312 tests, with 21 environmental failures (the Imagick woff2 font delegate,maxminddb, an empty JWT signing key, and a DNS lookup). The same 21 fail onmainwith the vendored1.0.1on this host, and none of them involve validators. CI runs the suite in the containerTeams/Http/Teams/Create.php,Functions/Http/Functions/Create.php,Network/Validator/Origin.phpand other Appwrite files that extend or useUtopia\Validatorcomposer validate --no-check-publish: valid (the only warning is the existingplatformexact-version one)composer update --lock, after the merge ofmain: the lock diff only removesutopia-php/validators1.0.1 and updates the content hashbin/monorepo split validators --dry-run:ff51aff7, which fast-forwards from the mirror headf0a08bd8, and its tree matchespackages/validatorsgit diff --check, and Pint over the whole repositoryMerge and follow-up
Merge with a merge commit. A squash drops the
git-subtree-*annotation and orphans the package from its mirror.The
utopia-php/validatorsmirror already has the canonicalmainruleset (id17509374), with the split app as an always-bypass actor, so the absorb ran with--skip-ruleset.After merge:
Splitpushes toutopia-php/validators.packages/validatorsfromutopia-php/monorepo.console,servers,http,queue,database,domains,dns,emails,storageandauditthere still requireutopia-php/validatorsfrom Packagist, and the mirror keeps serving it.getList()returns in loose mode, which is observable. If we want it, it should be re-opened here againstpackages/validators.CallingCodevalidator andPhonechanges). It touchespackages/validatorsin the monorepo, so its validators half has to move here before the monorepo copy is retired.Utopia\Validatormoves toUtopia\Validator\Validator,validate's spelling rule (<Ns>lowercased equals the package name) rejectsValidatorforvalidators. Step B needs either an exception or a decision on that rule, alongside removing theBAREentry.🤖 Generated with Claude Code