{"id":2930,"date":"2024-12-15T12:22:03","date_gmt":"2024-12-15T03:22:03","guid":{"rendered":"https:\/\/www.agile-software.site\/?p=2930"},"modified":"2024-12-15T12:22:04","modified_gmt":"2024-12-15T03:22:04","slug":"2930","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=2930","title":{"rendered":""},"content":{"rendered":"\n<p><code>createInsertSchema<\/code>\u306e\u4ee3\u308f\u308a\u306b<code>z.object()<\/code>\u3092\u76f4\u63a5\u4f7f\u7528\u3059\u308b\u7406\u7531\u306f\u3001\u4e3b\u306b\u67d4\u8edf\u6027\u3068\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u6027\u306b\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3044\u304f\u3064\u304b\u306e\u7406\u7531\u3092\u6319\u3052\u307e\u3059\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u67d4\u8edf\u6027<\/strong>: <code>z.object()<\/code>\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b9\u30ad\u30fc\u30de\u3092\u3088\u308a\u7d30\u304b\u304f\u5236\u5fa1\u3067\u304d\u307e\u3059\u3002\u7279\u5b9a\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3084\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30eb\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u76f4\u63a5\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba<\/strong>: <code>z.object()<\/code>\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u3054\u3068\u306b\u7570\u306a\u308b\u5236\u7d04\u3084\u6761\u4ef6\u3092\u8a2d\u5b9a\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\u3059\u308b\u969b\u306b\u4fbf\u5229\u3067\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30b7\u30f3\u30d7\u30eb\u306a\u69cb\u6587<\/strong>: <code>z.object()<\/code>\u306f\u3001\u76f4\u63a5\u7684\u3067\u5206\u304b\u308a\u3084\u3059\u3044\u69cb\u6587\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30b9\u30ad\u30fc\u30de\u306e\u5b9a\u7fa9\u3084\u8aad\u307f\u53d6\u308a\u304c\u7c21\u5358\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306e\u4e00\u8cab\u6027<\/strong>: Zod\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001\u4ed6\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3084\u30b9\u30ad\u30fc\u30de\u751f\u6210\u30c4\u30fc\u30eb\u3068\u4e00\u8cab\u6027\u306e\u3042\u308b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3067\u7d71\u4e00\u3055\u308c\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u65b9\u6cd5\u3092\u7dad\u6301\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u5177\u4f53\u7684\u306a\u4f8b\u3092\u6319\u3052\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>import { z } from &#39;zod&#39;;\n\nconst UserSchema = z.object({\n  username: z.string().min(1, &quot;Username is required&quot;),\n  email: z.string().email(&quot;Invalid email address&quot;),\n  password: z.string().min(6, &quot;Password must be at least 6 characters long&quot;)\n});\n\n\/\/ \u4f7f\u7528\u4f8b\nconst userData = {\n  username: &quot;user123&quot;,\n  email: &quot;user@example.com&quot;,\n  password: &quot;password123&quot;\n};\n\nconst parsedUser = UserSchema<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>createInsertSchema\u306e\u4ee3\u308f\u308a\u306bz.object()\u3092\u76f4\u63a5\u4f7f\u7528\u3059\u308b\u7406\u7531\u306f\u3001\u4e3b\u306b\u67d4\u8edf\u6027\u3068\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u6027\u306b\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3044\u304f\u3064\u304b\u306e\u7406\u7531\u3092\u6319\u3052\u307e\u3059\uff1a \u5177\u4f53\u7684\u306a\u4f8b\u3092\u6319\u3052\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2930","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2930"}],"version-history":[{"count":1,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2930\/revisions"}],"predecessor-version":[{"id":2935,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2930\/revisions\/2935"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}