Repository navigation
feat: support validation in synchronous code paths - #158
Merged
Merged
Conversation
Use the published compiler, strengthen metadata and messages-provider coverage, and add a registration benchmark comparing async and sync validation.
Contributor
|
Looks good. Should we update the docs too? |
Member
Author
|
Done: vinejs/vinejs.dev#55 |
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.
Vine currently always returns a Promise, which prevents its use in code paths that require a synchronous result.
This adds
validateSync()andtryValidateSync()to validators and thevineshortcuts. Synchronous compilation happens on first use and is cached. Existing async APIs and Standard Schema behavior remain unchanged. Requires@vinejs/compiler@4.2.0.Performance
This is not a performance optimization. Synchronous rules were already compiled into direct calls without
await. The main benefit is using Vine where returning or awaiting a Promise is not possible.A registration benchmark with email, username and password rules showed similar performance: 2.41–2.48 µs async versus 2.31–2.42 µs sync. Sample ranges overlap, so no substantial gain is established.
Checks
Runtime and type tests, lint, typecheck and build pass. Independent reviews by Sol 6.1 and Claude Code Opus found no runtime defects.