Repository navigation
refactor(web_core): validate catalog entries through Standard Schema - #30
Closed
louis-bompart wants to merge 1 commit into
Closed
louis-bompart wants to merge 1 commit into
louis-bompart wants to merge 1 commit into
Conversation
The core now validates a catalog entry or theme as a synchronous Standard Schema validator rather than through the Zod API, so the schema compiled from a catalog definition no longer has to be a Zod schema for the core to use it. componentSchemaOf, functionSchemaOf and themeSchemaOf return an A2uiValidator. validateEntry replaces safeParseEntry: it validates with the document's schema, then with the entry's own Zod 3 or library schema, and returns the Standard Schema result. PayloadValidator formats its issues with formatA2uiSchemaIssue, which formats a Zod issue exactly as formatZodIssue does, and the function invoker writes them as a Zod error's message did. Inspection takes an InspectableSchema, an entry's own schema or a validator compiled from a definition, and GenericBinder binds such a validator through its definition. For every component and function of the 61 catalog documents in the repository and the code basic catalogs, 10,497 payloads validate with the same results and messages as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
Collaborator
Author
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.
Description
This PR is the first half of Layer 4, stacked on #29. The core now validates catalog entries and themes as synchronous Standard Schema validators instead of through the Zod API. The schema compiled from a catalog definition no longer has to be a Zod schema for the core to use it, which the compiler seam in the second half of Layer 4 needs.
componentSchemaOf,functionSchemaOfandthemeSchemaOfreturn anA2uiValidatorinstead of a Zod type. The loader still compiles to Zod 3, which implements Standard Schema.validateEntryreplacessafeParseEntry. It validates with the schema compiled from the entry's document, then with the entry's own Zod 3 or library schema, throughvalidateA2uiSchema, and returns the Standard Schema result. A JSON Schema object adds nothing to the document's check, as before.PayloadValidatorformats issues withformatA2uiSchemaIssue, which formats a Zod issue exactly asformatZodIssuedoes. The function invoker writes the issues as indented JSON, as a Zod error's message did.InspectableSchema: an entry's ownEntrySchema, or a validator compiled from a definition.GenericBinderbinds a compiled validator through its definition (hasDefinitionView). Its constructor's parameter type widens, so existing callers are unaffected.What changes for callers. For an entry whose own schema comes from another library,
A2uiValidationError.detailsand the details of a function argument error now hold that library's issues as it reports them. Before, they were converted to Zod issues. This matches what the protocol validators of #26 expose. The changelog says so.The common-type checks in
PayloadValidator(accessibility attributes, component metadata) still use their Zod mirrors. They belong to the core, not to a catalog, and move with the core's own Zod later.The second half of Layer 4 comes next:
Catalog.fromJson()takes a compiler that turns a resolved definition into a validator, with an Ajv test compiler.Validation
yarn buildnode --test "dist/**/*.test.js": 1285 passing, 0 failing, 21 todonode tests/conformance/conformance_test.mjs: all vectors passingyarn lint: 0 errorsyarn format:checkyarn testintypescript/catalogs/{mcp,vegachart},typescript/renderers/{lit,react}andtypescript/agents/a2ui_agent. Angular passes apart fromtest:closure-compiler, which needs Java 21.null, a string, an unknown key, and eight kinds of value for each declared property.validateEntrytests cover:Part of a2ui-project#2160
Pre-launch Checklist
One time:
For this PR:
🤖 Generated with Claude Code