Skip to content

feat(compiler): add synchronous compilation - #2

Open
RomainLanz wants to merge 1 commit into
4.xfrom
feat/sync-compilation
Open

RomainLanz wants to merge 1 commit into
4.xfrom
feat/sync-compilation

Conversation

@RomainLanz

Copy link
Copy Markdown
Member

Compiler.compile() always returns an async function, even when every validation rule is synchronous. This prevents callers from running validation with a synchronous contract.

This adds an explicit Compiler.compileSync() API using the existing code generator and node compilers. Synchronous compilation rejects rules declared as async. At runtime, it also rejects a Promise or thenable returned by a rule marked as synchronous.

Compiler.compile() keeps its existing behavior.

The test suite covers direct synchronous returns and errors, nested structures, invalid async rules, misdeclared thenables, and the existing asynchronous path.

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.

1 participant