refactor!: drop the class-level ~standard, leaving instance as the entry point - #16
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the entity class-level Standard Schema entry point (~standard) so that Entity.instance is the sole composable/Standard-Schema surface, aligning with how zod v4 already implements Standard Schema on schemas and avoiding having two non-interchangeable spellings of “the validator”.
Changes:
- Dropped
~standardfrom the entity static type surface (EntityStatic) and from runtime attachment (attachInstance). - Updated docs and examples to consistently use
fromSchema(Organization.instance). - Updated tests to assert
instanceremains the Standard Schema entry point and thatinstancestays non-enumerable and cached.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates Standard Schema guidance/examples to route through Organization.instance. |
| packages/entity/src/types.ts | Removes ~standard from the EntityStatic type surface. |
| packages/entity/src/instance.ts | Removes runtime definition of class-level ~standard; keeps lazy, cached instance. |
| packages/entity/src/instance.spec.ts | Adjusts tests to validate instance as Standard Schema entry point and removes class-level ~standard expectations. |
| packages/entity/README.md | Removes ~standard from the documented statics table; reinforces instance as the composable surface. |
| CLAUDE.md | Updates module documentation for instance.ts and adds the missing union.ts entry. |
| .changeset/drop-class-standard-schema.md | Adds a breaking-change note and migration guidance (fromSchema(X) → fromSchema(X.instance)). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it bought, measured
Exactly one thing: letting you drop
.instance.instanceis a zod schema andzod implements Standard Schema, so it already carries
~standardand isaccepted by anything that takes one.
What it cost
The class was a validator in some contexts and not others. The README had
to say so:
Two spellings of one concept that are not interchangeable, and you had to know
which context takes which. That is the same shape of problem that removed
encode()and collapseddecode/make.#14 sharpened it further:
.instanceis now a valid entity field, so it isunambiguously the composable surface. The class-level shortcut was the odd one
out.
Changes
attachInstanceloses its second accessor; its comment no longer has toexplain rebuilding "the schema (and its
~standard)"EntityStaticloses the memberinstance.spec.tskeeps the same coverage againstinstance, and gains anexplicit assertion that
instanceis a Standard Schema — which is the factthis change relies on
CLAUDE.mdupdated;CLAUDE.mdalso gains theunion.tsentry it was missing from feat: add union(), a union of entities that is itself entity-like #15Gate
format --check,lint,typecheck(three passes),test(108, 10 files),knip,build— all green.