mcpField
R
regle-migrate-vuelidate

regle-migrate-vuelidate

github.com/victorgarciaesgi开发51354 次安装2 周前更新
代码仓库

关于 regle-migrate-vuelidate

将 Vuelidate 表单验证迁移到 Regle 的技能,面向开发者逐步处理表单、规则、状态和绑定,并依据文档避免猜测。

主要功能

  1. 01分步骤迁移清单
  2. 02转换表单状态与规则
  3. 03更新验证属性和绑定
  4. 04指导作用域验证迁移
  5. 05编写自定义规则前检查内置规则

适用场景

  1. 01将 Vue 表单从 Vuelidate 迁至 Regle
  2. 02更新使用作用域验证的嵌套组件

MCP 相关

如果 Regle MCP 服务可用,技能会优先查询其 API 细节和迁移指导。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/victorgarciaesgi/regle --skill regle-migrate-vuelidate

安装后在 Claude Code 中输入/regle-migrate-vuelidate确认已加载。

附带文件references/migration-steps.md

详细介绍

将 Vuelidate 迁移到 Regle

将使用 Vuelidate 构建的表单验证转换为 Regle。请将每个表单、规则和验证属性都考虑在内。

知识来源

按优先级使用以下来源了解 API 详情、模式和 TypeScript 类型:

  1. Regle MCP 服务(如果可用):搜索“Migrate from Vuelidate”和其他主题。如果未启用,请让用户启用,或自行启用。
  2. Regle 相关技能:
    • regle — useRegle、验证属性($error、$errors、$validate、$reset)、修饰符、错误显示。
    • regle-rules — 内置规则、createRule、包装器(withMessage)、运算符(requiredIf、applyIf、assignIf)。
    • regle-advanced — 作用域验证(useScopedRegle、useCollectScope)、集合、异步规则、服务端错误、$self。
    • regle-schemas — 基于架构的验证(Zod、Valibot、ArkType),适用于使用架构的表单。
    • regle-typescript — inferRules、规则和属性的类型(RegleRoot、InferRegleRoot、SuperCompatibleRegleRoot)。
  3. 文档 / 便于大模型处理的参考资料:https://reglejs.dev/introduction/migrate-from-vuelidate、https://reglejs.dev/llms.txt(术语表)、https://reglejs.dev/llms-full.txt(完整文档)。

全局规则

  • Regle 默认将 $autoDirty 设为 true——不要设置它,并移除手动调用的 $touch()。
  • 重命名组合式函数的结果时,保留变量名:Vuelidate 的 v$(或任何其他名称)应使用相同标识符改为 r$。
  • 将表单值绑定到 Regle 的 *.$value 属性。
  • 不要使用 r$.$fields.xxx;直接通过 r$.xxx 访问字段。
  • 编写自定义规则之前,先检查是否有等效的内置规则。
  • 如果某个具体情况不明确,请询问用户,或保持不变,而不要猜测。

工作流

复制此检查清单并跟踪进度:

- [ ] 1. Identify the Vuelidate form
- [ ] 2. Replace the imports
- [ ] 3. Replace the state
- [ ] 4. Replace the validation rules
- [ ] 5. Replace the validation properties
- [ ] 6. Replace binding events
- [ ] 7. Replace nested-component validation (scoped)
- [ ] 8. Inspect form propagation (parent <-> child)
- [ ] 9. Self-review and run typecheck + lint

按照 migration-steps 中的详细分步说明操作。

评论

支持 Markdown