[{"data":1,"prerenderedAt":363},["ShallowReactive",2],{"content-\u002Fe\u002Faf15":3},{"id":4,"title":5,"body":6,"condition":355,"description":356,"extension":357,"meta":358,"navigation":193,"path":359,"seo":360,"stem":361,"__hash__":362},"errors\u002Fe\u002Faf15.md","AF15",{"type":7,"value":8,"toc":351},"minimark",[9,13,20,23,33,45,50,64,114,132,139,143,146,223,226,307,310,339,347],[10,11,5],"h1",{"id":12},"af15",[14,15,16],"p",{},[17,18,19],"strong",{},"The schema root is not a shape that can hold keys, so there is nothing for Attaform to address.",[14,21,22],{},"In development this reads:",[24,25,26],"blockquote",{},[14,27,28,32],{},[29,30,31],"span",{},"attaform\u002Fzod"," useForm schema root must be a ZodObject, ZodRecord, or ZodDiscriminatedUnion (got 'string'). Wrap other shapes under a key.",[14,34,35,36,40,41,44],{},"The Zod v3 adapter prints the mirror of that, prefixed ",[37,38,39],"code",{},"[attaform\u002Fzod-v3]"," and naming the root by its Zod type (",[37,42,43],{},"'ZodString'",") rather than by its kind. Either way, the production message carries that same name after the code.",[46,47,49],"h2",{"id":48},"what-happened","What happened",[14,51,52,53,56,57,56,60,63],{},"A form is a set of addressable fields. Every part of Attaform that you reach for names a path into that set: ",[37,54,55],{},"register('email')",", ",[37,58,59],{},"form.errors('address.city')",[37,61,62],{},"form.values.total",". A root has to be able to hold keys for any of those to mean anything, and three shapes can:",[65,66,67,80],"table",{},[68,69,70],"thead",{},[71,72,73,77],"tr",{},[74,75,76],"th",{},"Root",[74,78,79],{},"What it models",[81,82,83,94,104],"tbody",{},[71,84,85,91],{},[86,87,88],"td",{},[37,89,90],{},"z.object({ ... })",[86,92,93],{},"A fixed set of fields, the common case",[71,95,96,101],{},[86,97,98],{},[37,99,100],{},"z.record(key, value)",[86,102,103],{},"A dictionary whose keys are known at runtime",[71,105,106,111],{},[86,107,108],{},[37,109,110],{},"z.discriminatedUnion(key, [ ... ])",[86,112,113],{},"A variant form; the active branch lifts its keys into one surface",[14,115,116,117,120,121,124,125,120,128,131],{},"A ",[37,118,119],{},"z.string()",", a ",[37,122,123],{},"z.array(...)",", a bare ",[37,126,127],{},"z.union(...)",[37,129,130],{},"z.map(...)",": none of these has a key to bind an input to.",[14,133,134,135,138],{},"This is the only shape of schema Attaform refuses, and it refuses on the absence of the one property the form engine needs, not on a list of kinds. ",[17,136,137],{},"Every Zod kind is welcome under a key",", including the ones with no obvious form representation. Attaform does not decide what a field is allowed to hold.",[46,140,142],{"id":141},"how-to-fix-it","How to fix it",[14,144,145],{},"Give the value a name:",[147,148,153],"pre",{"className":149,"code":150,"language":151,"meta":152,"style":152},"language-ts shiki shiki-themes github-light github-dark","\u002F\u002F Refused: nothing to address.\nconst schema = z.string()\n\n\u002F\u002F Accepted.\nconst schema = z.object({ nickname: z.string() })\n","ts","",[37,154,155,163,188,195,201],{"__ignoreMap":152},[29,156,159],{"class":157,"line":158},"line",1,[29,160,162],{"class":161},"sJ8bj","\u002F\u002F Refused: nothing to address.\n",[29,164,166,170,174,177,181,185],{"class":157,"line":165},2,[29,167,169],{"class":168},"szBVR","const",[29,171,173],{"class":172},"sj4cs"," schema",[29,175,176],{"class":168}," =",[29,178,180],{"class":179},"sVt8B"," z.",[29,182,184],{"class":183},"sScJk","string",[29,186,187],{"class":179},"()\n",[29,189,191],{"class":157,"line":190},3,[29,192,194],{"emptyLinePlaceholder":193},true,"\n",[29,196,198],{"class":157,"line":197},4,[29,199,200],{"class":161},"\u002F\u002F Accepted.\n",[29,202,204,206,208,210,212,215,218,220],{"class":157,"line":203},5,[29,205,169],{"class":168},[29,207,173],{"class":172},[29,209,176],{"class":168},[29,211,180],{"class":179},[29,213,214],{"class":183},"object",[29,216,217],{"class":179},"({ nickname: z.",[29,219,184],{"class":183},[29,221,222],{"class":179},"() })\n",[14,224,225],{},"The same move works for every other refused root:",[147,227,229],{"className":149,"code":228,"language":151,"meta":152,"style":152},"const schema = z.object({\n  tags: z.array(z.string()),\n  lookup: z.map(z.string(), z.number()),\n  payload: z.union([z.string(), z.number()]),\n})\n",[37,230,231,246,262,282,302],{"__ignoreMap":152},[29,232,233,235,237,239,241,243],{"class":157,"line":158},[29,234,169],{"class":168},[29,236,173],{"class":172},[29,238,176],{"class":168},[29,240,180],{"class":179},[29,242,214],{"class":183},[29,244,245],{"class":179},"({\n",[29,247,248,251,254,257,259],{"class":157,"line":165},[29,249,250],{"class":179},"  tags: z.",[29,252,253],{"class":183},"array",[29,255,256],{"class":179},"(z.",[29,258,184],{"class":183},[29,260,261],{"class":179},"()),\n",[29,263,264,267,270,272,274,277,280],{"class":157,"line":190},[29,265,266],{"class":179},"  lookup: z.",[29,268,269],{"class":183},"map",[29,271,256],{"class":179},[29,273,184],{"class":183},[29,275,276],{"class":179},"(), z.",[29,278,279],{"class":183},"number",[29,281,261],{"class":179},[29,283,284,287,290,293,295,297,299],{"class":157,"line":197},[29,285,286],{"class":179},"  payload: z.",[29,288,289],{"class":183},"union",[29,291,292],{"class":179},"([z.",[29,294,184],{"class":183},[29,296,276],{"class":179},[29,298,279],{"class":183},[29,300,301],{"class":179},"()]),\n",[29,303,304],{"class":157,"line":203},[29,305,306],{"class":179},"})\n",[14,308,309],{},"If the form genuinely has runtime-known keys rather than a fixed shape, reach for a record root instead of wrapping:",[147,311,313],{"className":149,"code":312,"language":151,"meta":152,"style":152},"const schema = z.record(z.string(), z.number())\n",[37,314,315],{"__ignoreMap":152},[29,316,317,319,321,323,325,328,330,332,334,336],{"class":157,"line":158},[29,318,169],{"class":168},[29,320,173],{"class":172},[29,322,176],{"class":168},[29,324,180],{"class":179},[29,326,327],{"class":183},"record",[29,329,256],{"class":179},[29,331,184],{"class":183},[29,333,276],{"class":179},[29,335,279],{"class":183},[29,337,338],{"class":179},"())\n",[14,340,341,346],{},[342,343,345],"a",{"href":344},"\u002Fdocs\u002Fschemas\u002Fcontract","The schema contract"," covers what Attaform asks of a schema and how the adapters read it.",[348,349,350],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":152,"searchDepth":165,"depth":165,"links":352},[353,354],{"id":48,"depth":165,"text":49},{"id":141,"depth":165,"text":142},"The `useForm` schema root cannot hold keys","The schema passed to useForm has a root that cannot hold keys, such as z.string() or z.array(). Wrap it under a key.","md",{},"\u002Fe\u002Faf15",{"title":5,"description":356},"e\u002Faf15","drNdWkj9c2xOk6L6C5GZxapkr0Tca8nAGq0OoilcJMM",1789484629220]