You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
发现于 #5186 的实施(对齐 FieldConstraintsSchema 到 FieldValidationRules 时按规则消费半径扫描文档示例)。Filed unassigned, not claiming. #5186 remains open until its own PR lands; this card is the docs-only follow-up.
发现于 #5186 的实施(对齐
FieldConstraintsSchema到FieldValidationRules时按规则消费半径扫描文档示例)。Filed unassigned, not claiming. #5186 remains open until its own PR lands; this card is the docs-only follow-up.现象
content/docs/blocks/forms.mdx的「Add Validation」小节(≈行 41-53)教读者写:{ "type": "input", "name": "email", "validation": { "pattern": "^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$", "message": "Please enter a valid email address" } }这是第三种方言,两个声明面都没有它:
pattern是扁平字符串 —— 公开 TS 契约FieldValidationRules.pattern是{ value, message }对象(手写FieldValidationRules在唯一读点既不校验也不归一:pattern.value写成 string(类型明确允许)被 react-hook-form 静默忽略,未识别的规则名同样静默丢弃 #5099 后value收成 RegExp);FormFieldSchema.validation的 zod 镜像(FieldConstraintsSchema)与FieldValidationRules形状完全不符:拒绝 TS 契约合法的对象形、放行渲染器从不读的扁平形 #5186 落地后 zod 面也已对齐,objectui validate会对这份示例的pattern具名拒绝并指引元数据路线(FieldSchema.pattern)。message在FieldValidationRules与FieldConstraintsSchema里从未存在过(消息一直住在各规则对象内部),任一时期的 zod 面都会把它静默 strip。即便在 #5186 之前,这份示例也从未跑过任何校验:
form.tsx的读点把validation原样展开给 react-hook-form,react-hook-form 只在pattern.value instanceof RegExp时才执行 pattern 规则 —— 照抄示例的读者得到的是「看起来有校验、实际零执行」(#5099 症状),现在则是 validate 时被具名拒绝。同族先例:#5118(plugin-form.mdx 的 validation 数组拼法,已关)修的是另一文件的另一方言,没有覆盖本文件。修法方向(docs-only)
JSON 面携带不了 RegExp,诚实的教法是指去元数据路线:字段声明上的
FieldSchema.pattern(字符串,由@object-ui/fields的buildValidationRules编译),或在 TS 示例里用pattern: { value: /…/, message: '…' }。顺带全文扫一遍content/docs/blocks/forms.mdx是否还有同方言的其它示例。复核:
Generated by Claude Code