[{"data":1,"prerenderedAt":102},["ShallowReactive",2],{"note-\u002Fnotes\u002Fschema-driven-forms":3},{"id":4,"title":5,"body":6,"category":87,"date":88,"description":89,"draft":90,"extension":91,"meta":92,"navigation":93,"path":94,"seo":95,"sourcePath":96,"stem":97,"tags":98,"__hash__":101},"notes\u002Fnotes\u002Fschema-driven-forms.md","Schema-Driven 表單思路",{"type":7,"value":8,"toc":78},"minimark",[9,13,17,20,23,49,52,55,66,69,72,75],[10,11,12],"h2",{"id":12},"問題",[14,15,16],"p",{},"當表單欄位一多，畫面、驗證、預設值常散落在元件各處，改一個規則要改好幾層。",[10,18,19],{"id":19},"做法",[14,21,22],{},"把欄位定義收成 schema，例如：",[24,25,26,40,46],"ul",{},[27,28,29,33,34,33,37],"li",{},[30,31,32],"code",{},"name"," \u002F ",[30,35,36],{},"type",[30,38,39],{},"label",[27,41,42,45],{},[30,43,44],{},"required","、驗證規則",[27,47,48],{},"預設值與顯示條件",[14,50,51],{},"UI 只負責「依 schema 渲染」，業務規則盡量留在 schema 或對應的 parser。",[10,53,54],{"id":54},"適合什麼時候",[24,56,57,60,63],{},[27,58,59],{},"欄位結構常變（後台、設定頁、標案表單）",[27,61,62],{},"同一套欄位要在多個流程重用",[27,64,65],{},"希望驗證與文案可被非 UI 層共用",[10,67,68],{"id":68},"代價",[14,70,71],{},"多一層抽象：簡單三欄表單不必上 schema。schema 本身也需要維護與型別約束。",[10,73,74],{"id":74},"小結",[14,76,77],{},"欄位一多、規則一複，就把「長什麼樣子」和「怎麼驗證」從畫面元件抽出去。Schema-driven 不是銀彈，但是複雜表單的好預設。",{"title":79,"searchDepth":80,"depth":80,"links":81},"",2,[82,83,84,85,86],{"id":12,"depth":80,"text":12},{"id":19,"depth":80,"text":19},{"id":54,"depth":80,"text":54},{"id":68,"depth":80,"text":68},{"id":74,"depth":80,"text":74},"other","2026-08-05","用 schema 描述欄位與驗證，讓複雜表單的結構、文案與規則集中管理。",false,"md",{},true,"\u002Fnotes\u002Fschema-driven-forms",{"title":5,"description":89},null,"notes\u002Fschema-driven-forms",[99,100],"Forms","Architecture","Of3jmcSLEfvz7bWDJOGIun7OJ0TrqVEM9rzI_vfrYMI",1788767747556]