feat(0): add useRules composable with Zod/Yup adapters#140
Open
johnleider wants to merge 1 commit intomasterfrom
Open
feat(0): add useRules composable with Zod/Yup adapters#140johnleider wants to merge 1 commit intomasterfrom
johnleider wants to merge 1 commit intomasterfrom
Conversation
Adds a new `useRules` plugin to @vuetify/v0 that provides: - Alias-based validation rules with token registry message storage - `createRules`, `createRulesPlugin`, `useRules`, `createRulesFallback` - 11 built-in aliases: required, minLength, maxLength, min, max, email, url, integer, decimal, pattern, phone - `useLocale` integration via `rules.<alias>` locale key pattern - Overridable messages via `messages` option in `createRules()` - `RulesContext` integration in `createForm()` via `rules: [...]` Adds Zod and Yup adapters as sub-path exports: - `@vuetify/v0/rules/adapters/zod` — `toRule(schema)` with duck-typed ZodSchema - `@vuetify/v0/rules/adapters/yup` — `toRule(schema)` with duck-typed YupSchema - Zero runtime dependency — structural interfaces only Adds documentation: - `composables/plugins/use-rules.md` with full API reference - `useLocale` integration section and 4-step message priority chain - Updated `composables/index.md` to list useRules in Plugins Also fixes knip.json to add explicit entry patterns for sub-path adapter files and root scripts, resolving false-positive unused file warnings.
|
commit: |
Contributor
|
I think it's might be better to support https://standardschema.dev/, and get broader validation libs support: Zod, Valibot, ArkType, and more |
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.
Summary
useRulesplugin to@vuetify/v0providing alias-based form validation rules with token registry message storage anduseLocaleintegration@vuetify/v0/rules/adapters/zodand@vuetify/v0/rules/adapters/yupsub-path exports for zero-dependency integration with Zod and Yup validation schemascomposables/plugins/use-rules.mdincludinguseLocaleintegration guideknip.jsonto explicitly list sub-path adapter files as entry pointsNew API
useRulespluginZod adapter
Yup adapter
Integration with
createFormTest plan
useRulescomposable: 66 tests covering all 11 built-in aliases,resolve(), custom aliases, locale fallback, Trinity pattern