{"id":3243,"date":"2025-03-24T08:46:36","date_gmt":"2025-03-23T23:46:36","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=3243"},"modified":"2025-03-24T08:47:07","modified_gmt":"2025-03-23T23:47:07","slug":"%e3%80%90laravel%e3%80%91%e3%83%90%e3%83%aa%e3%83%87%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%9f%ba%e7%a4%8e%e3%81%8b%e3%82%89%e5%ae%9f%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=3243","title":{"rendered":"\u3010Laravel\u3011\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u57fa\u790e\u304b\u3089\u5b9f\u8df5\u307e\u3067\u89e3\u8aac\u3059\u308b7\u3064\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Laravel\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u57fa\u790e\u77e5\u8b58<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u95a2\u4fc2\u6027<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027\u3068\u5229\u70b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">\u57fa\u672c\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u5b9f\u88c5\u65b9\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-5\">\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-6\">\u3088\u304f\u4f7f\u7528\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3068\u4f7f\u7528\u4f8b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-7\">\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210\u3068\u6d3b\u7528<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-8\">\u72ec\u81ea\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u4f5c\u6210\u624b\u9806<\/a>      <\/li>      <li>        <a href=\"#i-9\">\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u305f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-10\">\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-11\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-12\">\u591a\u8a00\u8a9e\u5bfe\u5fdc\u306e\u5b9f\u88c5\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-13\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u52d5\u7684\u306a\u5909\u66f4<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-14\">\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b97\u9078<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-15\">1. \u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u9069\u5207\u306a\u4f7f\u7528<\/a>      <\/li>      <li>        <a href=\"#i-16\">2. \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u518d\u5229\u7528<\/a>      <\/li>      <li>        <a href=\"#i-17\">3. \u30bb\u30ad\u30e5\u30a2\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u8a08<\/a>      <\/li>      <li>        <a href=\"#i-18\">4. \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u30eb\u30fc\u30eb\u8a2d\u8a08<\/a>      <\/li>      <li>        <a href=\"#i-19\">5. \u30c6\u30b9\u30c8\u53ef\u80fd\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-20\">6. \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u6700\u9069\u5316<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-21\">7. \u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-22\">\u5b9f\u8df5\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-23\">\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-24\">\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-25\">API \u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-26\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-27\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u89e3\u6c7a\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-32\">\u30c7\u30d0\u30c3\u30b0\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Laravel\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u57fa\u790e\u77e5\u8b58<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u95a2\u4fc2\u6027<\/h3>\n\n\n\n<p>Laravel\u306b\u304a\u3051\u308b\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4fe1\u983c\u6027\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u78ba\u4fdd\u3059\u308b\u4e0a\u3067\u91cd\u8981\u306a\u95a2\u4fc2\u6027\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u691c\u8a3c\u3057\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306b\u6e21\u3059\u524d\u306e\u300c\u9580\u756a\u300d\u3068\u3057\u3066\u306e\u5f79\u5272\u3092\u679c\u305f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u51e6\u7406\u30d5\u30ed\u30fc\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u53d7\u4fe1<\/li>\n\n\n\n<li>\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u30af\u30e9\u30b9\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c<\/li>\n\n\n\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6210\u529f\u6642\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30e1\u30bd\u30c3\u30c9\u5b9f\u884c<\/li>\n\n\n\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5931\u6557\u6642\u306e\u30a8\u30e9\u30fc\u30ec\u30b9\u30dd\u30f3\u30b9\u8fd4\u5374<\/li>\n<\/ol>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u57fa\u672c\u7684\u306a\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreUserRequest extends FormRequest\n{\n    public function authorize()\n    {\n        return true; \/\/ \u8a8d\u8a3c\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\n    }\n\n    public function rules()\n    {\n        return [\n            'name' =&gt; 'required|string|max:255',\n            'email' =&gt; 'required|email|unique:users',\n            'password' =&gt; 'required|min:8|confirmed'\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027\u3068\u5229\u70b9<\/h3>\n\n\n\n<p>Laravel\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u9069\u5207\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u91cd\u8981\u306a\u5229\u70b9\u304c\u5f97\u3089\u308c\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u6b63\u306a\u30c7\u30fc\u30bf\u306e\u6df7\u5165\u3092\u9632\u6b62<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e00\u8cab\u6027\u3092\u7dad\u6301<\/li>\n\n\n\n<li>\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306e\u9075\u5b88\u3092\u5f37\u5236<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0\uff08XSS\uff09\u306e\u9632\u6b62<\/li>\n\n\n\n<li>SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u306e\u9632\u6b62<\/li>\n\n\n\n<li>\u610f\u56f3\u3057\u306a\u3044\u30c7\u30fc\u30bf\u64cd\u4f5c\u306e\u9632\u6b62<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u958b\u767a\u52b9\u7387\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5171\u901a\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u518d\u5229\u7528<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u7d71\u4e00\u5316<\/li>\n\n\n\n<li>\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e6\u30fc\u30b6\u30fc\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u306e\u6539\u5584<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5373\u6642\u306e\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u63d0\u4f9b<\/li>\n\n\n\n<li>\u660e\u78ba\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u8868\u793a<\/li>\n\n\n\n<li>\u30d5\u30a9\u30fc\u30e0\u5165\u529b\u306e\u88dc\u52a9<\/li>\n<\/ul>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3059\u308b\u969b\u306e\u57fa\u672c\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u306e\u5b9f\u88c5\u4f8b\npublic function store(Request $request)\n{\n    $validated = $request-&gt;validate([\n        'title' =&gt; 'required|max:255',\n        'body' =&gt; 'required',\n        'publish_at' =&gt; 'nullable|date'\n    ]);\n\n    \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6210\u529f\u5f8c\u306e\u51e6\u7406\n    Post::create($validated);\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001Laravel\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u54c1\u8cea\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306e\u91cd\u8981\u306a\u8981\u7d20\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002\u9069\u5207\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u306b\u3088\u308a\u3001\u958b\u767a\u8005\u306f\u3088\u308a\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u52b9\u7387\u7684\u306b\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">\u57fa\u672c\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u306f\u3001\u6700\u3082\u76f4\u63a5\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u3067\u3059\u3002\u7279\u306b\u5c0f\u898f\u6a21\u306a\u30d5\u30a9\u30fc\u30e0\u3084\u3001\u7279\u6b8a\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u304c\u5fc5\u8981\u306a\u3044\u5834\u5408\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function store(Request $request)\n{\n    \/\/ \u57fa\u672c\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\n    $validated = $request-&gt;validate([\n        'name' =&gt; 'required|string|max:255',\n        'email' =&gt; 'required|email|unique:users',\n        'age' =&gt; 'required|integer|min:18',\n        'website' =&gt; 'nullable|url',\n        'profile_image' =&gt; 'nullable|image|max:2048'\n    ]);\n\n    \/\/ validate\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u305f\u5834\u5408\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    try {\n        $request-&gt;validate([\n            'title' =&gt; 'required|unique:posts|max:255',\n            'body' =&gt; 'required',\n        ]);\n    } catch (ValidationException $e) {\n        return redirect()-&gt;back()\n            -&gt;withErrors($e-&gt;errors())\n            -&gt;withInput();\n    }\n}<\/pre>\n\n\n\n<p>\u307e\u305f\u3001<code>validateWithBag<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u7279\u5b9a\u306e\u30a8\u30e9\u30fc\u30d0\u30c3\u30b0\u306b\u683c\u7d0d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$validated = $request-&gt;validateWithBag('post', [\n    'title' =&gt; 'required|unique:posts|max:255',\n    'body' =&gt; 'required',\n]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u5927\u898f\u6a21\u306a\u30d5\u30a9\u30fc\u30e0\u3084\u3001\u8907\u6570\u306e\u5834\u6240\u3067\u518d\u5229\u7528\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306b\u306f\u3001\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u30af\u30e9\u30b9\u306e\u4f7f\u7528\u304c\u63a8\u5968\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass UpdateUserRequest extends FormRequest\n{\n    public function authorize()\n    {\n        \/\/ \u30e6\u30fc\u30b6\u30fc\u304c\u73fe\u5728\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u66f4\u65b0\u3067\u304d\u308b\u304b\u78ba\u8a8d\n        return $this-&gt;user()-&gt;can('update', $this-&gt;route('user'));\n    }\n\n    public function rules()\n    {\n        return [\n            'name' =&gt; 'required|string|max:255',\n            'email' =&gt; 'required|email|unique:users,email,' . $this-&gt;user-&gt;id,\n            'password' =&gt; 'nullable|min:8|confirmed',\n            'role' =&gt; ['required', Rule::in(['admin', 'user', 'editor'])],\n            'settings' =&gt; 'required|array',\n            'settings.notifications' =&gt; 'required|boolean'\n        ];\n    }\n\n    public function messages()\n    {\n        return [\n            'email.unique' =&gt; '\u6307\u5b9a\u3055\u308c\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u65e2\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002',\n            'password.confirmed' =&gt; '\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4e00\u81f4\u3057\u307e\u305b\u3093\u3002'\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u3088\u304f\u4f7f\u7528\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3068\u4f7f\u7528\u4f8b<\/h3>\n\n\n\n<p>Laravel\u306b\u306f\u3001\u69d8\u3005\u306a\u7528\u9014\u306b\u5bfe\u5fdc\u3059\u308b\u8c4a\u5bcc\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u4e3b\u8981\u306a\u30eb\u30fc\u30eb\u3068\u305d\u306e\u4f7f\u7528\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6587\u5b57\u5217\u95a2\u9023\u306e\u30eb\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'name' =&gt; 'string|min:2|max:255',\n    'description' =&gt; 'nullable|string',\n    'slug' =&gt; 'required|string|alpha_dash|unique:posts'\n];<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u6570\u5024\u95a2\u9023\u306e\u30eb\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'age' =&gt; 'required|integer|between:18,60',\n    'price' =&gt; 'required|numeric|min:0',\n    'quantity' =&gt; 'required|integer|gt:0'\n];<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u65e5\u4ed8\u95a2\u9023\u306e\u30eb\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'birth_date' =&gt; 'required|date|before:today',\n    'start_date' =&gt; 'required|date',\n    'end_date' =&gt; 'required|date|after:start_date'\n];<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u30d5\u30a1\u30a4\u30eb\u95a2\u9023\u306e\u30eb\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'photo' =&gt; 'required|image|mimes:jpeg,png,jpg|max:2048',\n    'document' =&gt; 'required|file|mimes:pdf,doc,docx|max:10240',\n    'attachments.*' =&gt; 'file|max:1024'\n];<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>\u914d\u5217\u95a2\u9023\u306e\u30eb\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'items' =&gt; 'required|array|min:1',\n    'items.*.id' =&gt; 'required|exists:products,id',\n    'items.*.quantity' =&gt; 'required|integer|min:1'\n];<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306f\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u67d4\u8edf\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u307e\u305f\u3001<code>sometimes<\/code>\u30eb\u30fc\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u6761\u4ef6\u4ed8\u304d\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3082\u5b9f\u88c5\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'payment_method' =&gt; 'required|in:credit_card,bank_transfer',\n    'card_number' =&gt; 'sometimes|required_if:payment_method,credit_card|string|size:16',\n    'bank_account' =&gt; 'sometimes|required_if:payment_method,bank_transfer|string'\n];<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5805\u7262\u306a\u30d5\u30a9\u30fc\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210\u3068\u6d3b\u7528<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u72ec\u81ea\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u4f5c\u6210\u624b\u9806<\/h3>\n\n\n\n<p>Laravel\u3067\u306f\u3001\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3067\u5bfe\u5fdc\u3067\u304d\u306a\u3044\u5834\u5408\u306b\u3001\u72ec\u81ea\u306e\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u4f5c\u6210\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Artisan\u30b3\u30de\u30f3\u30c9\u3067\u30eb\u30fc\u30eb\u3092\u751f\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan make:rule PostalCode<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30eb\u30fc\u30eb\u30af\u30e9\u30b9\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules;\n\nuse Illuminate\\Contracts\\Validation\\Rule;\n\nclass PostalCode implements Rule\n{\n    public function passes($attribute, $value)\n    {\n        \/\/ \u90f5\u4fbf\u756a\u53f7\u5f62\u5f0f\uff08123-4567\uff09\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n        return preg_match('\/^\\d{3}-\\d{4}$\/', $value);\n    }\n\n    public function message()\n    {\n        return ':attribute\u306f\u6b63\u3057\u3044\u90f5\u4fbf\u756a\u53f7\u5f62\u5f0f\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002';\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30eb\u306e\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use App\\Rules\\PostalCode;\n\n$request-&gt;validate([\n    'postal_code' =&gt; ['required', new PostalCode],\n]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u305f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u305f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u8907\u96d1\u306a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u304c\u5fc5\u8981\u306a\u5834\u5408\u306b\u7279\u306b\u6709\u7528\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules;\n\nuse Illuminate\\Contracts\\Validation\\Rule;\n\nclass PhoneNumber implements Rule\n{\n    private $pattern = '\/^(0[0-9]{1,4}-[0-9]{1,4}-[0-9]{4})$\/';\n\n    public function passes($attribute, $value)\n    {\n        return preg_match($this-&gt;pattern, $value);\n    }\n\n    public function message()\n    {\n        return ':attribute\u306f\u6b63\u3057\u3044\u96fb\u8a71\u756a\u53f7\u5f62\u5f0f\uff08\u4f8b\uff1a03-1234-5678\uff09\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002';\n    }\n}<\/pre>\n\n\n\n<p>\u307e\u305f\u3001\u30af\u30ed\u30fc\u30b8\u30e3\u3092\u4f7f\u7528\u3057\u3066\u76f4\u63a5\u6b63\u898f\u8868\u73fe\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'username' =&gt; [\n        'required',\n        function ($attribute, $value, $fail) {\n            if (!preg_match('\/^[a-z0-9_-]{3,16}$\/', $value)) {\n                $fail('\u30e6\u30fc\u30b6\u30fc\u540d\u306f3\u301c16\u6587\u5b57\u306e\u534a\u89d2\u82f1\u6570\u5b57\u3001\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u3001\u30cf\u30a4\u30d5\u30f3\u306e\u307f\u4f7f\u7528\u53ef\u80fd\u3067\u3059\u3002');\n            }\n        }\n    ]\n];<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u306b\u306f\u3001\u8907\u6570\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b7\u30f3\u30d7\u30eb\u306a\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function rules()\n{\n    return [\n        'payment_type' =&gt; 'required|in:credit,bank,cash',\n        'card_number' =&gt; 'required_if:payment_type,credit',\n        'expiry_date' =&gt; 'required_if:payment_type,credit|date_format:Y-m',\n        'bank_account' =&gt; 'required_if:payment_type,bank'\n    ];\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u52d5\u7684\u306a\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function rules()\n{\n    $rules = [\n        'title' =&gt; 'required|string|max:255',\n        'content' =&gt; 'required|string'\n    ];\n\n    if ($this-&gt;isMethod('PUT')) {\n        $rules['publish_date'] = 'required|date|after:today';\n        $rules['category_id'] = 'required|exists:categories,id';\n    }\n\n    return $rules;\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u8907\u96d1\u306a\u6761\u4ef6\u30ed\u30b8\u30c3\u30af\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules;\n\nuse Illuminate\\Contracts\\Validation\\Rule;\n\nclass ComplexDateValidation implements Rule\n{\n    private $dependentField;\n    private $type;\n\n    public function __construct($dependentField, $type)\n    {\n        $this-&gt;dependentField = $dependentField;\n        $this-&gt;type = $type;\n    }\n\n    public function passes($attribute, $value)\n    {\n        $dependentValue = request()-&gt;input($this-&gt;dependentField);\n\n        switch ($this-&gt;type) {\n            case 'future':\n                return strtotime($value) &gt; strtotime($dependentValue);\n            case 'past':\n                return strtotime($value) &lt; strtotime($dependentValue);\n            case 'same_month':\n                return date('Y-m', strtotime($value)) === \n                       date('Y-m', strtotime($dependentValue));\n            default:\n                return false;\n        }\n    }\n\n    public function message()\n    {\n        return ':attribute\u306f\u6307\u5b9a\u3055\u308c\u305f\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u307e\u305b\u3093\u3002';\n    }\n}<\/pre>\n\n\n\n<p>\u4f7f\u7528\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'start_date' =&gt; 'required|date',\n    'end_date' =&gt; ['required', 'date', new ComplexDateValidation('start_date', 'future')],\n    'report_date' =&gt; ['required', 'date', new ComplexDateValidation('end_date', 'same_month')]\n];<\/pre>\n\n\n\n<p>\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u56fa\u6709\u306e\u8981\u4ef6\u306b\u5408\u308f\u305b\u305f\u67d4\u8edf\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u518d\u5229\u7528\u53ef\u80fd\u306a\u30eb\u30fc\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u91cd\u8907\u3092\u907f\u3051\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-11\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u591a\u8a00\u8a9e\u5bfe\u5fdc\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h3>\n\n\n\n<p>Laravel\u3067\u306f\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u591a\u8a00\u8a9e\u5bfe\u5fdc\u3092\u7c21\u5358\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u4e3b\u8981\u306a\u5b9f\u88c5\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8a00\u8a9e\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<p><code>resources\/lang\/ja\/validation.php<\/code>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">return [\n    'required' =&gt; ':attribute\u306f\u5fc5\u9808\u9805\u76ee\u3067\u3059\u3002',\n    'email' =&gt; ':attribute\u306b\u306f\u6709\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002',\n    'min' =&gt; [\n        'numeric' =&gt; ':attribute\u306b\u306f:min\u4ee5\u4e0a\u306e\u6570\u5024\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002',\n        'string' =&gt; ':attribute\u306b\u306f:min\u6587\u5b57\u4ee5\u4e0a\u306e\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002',\n    ],\n    'attributes' =&gt; [\n        'name' =&gt; '\u540d\u524d',\n        'email' =&gt; '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9',\n        'password' =&gt; '\u30d1\u30b9\u30ef\u30fc\u30c9',\n        'confirm_password' =&gt; '\u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u78ba\u8a8d\uff09',\n    ],\n    'custom' =&gt; [\n        'email' =&gt; [\n            'unique' =&gt; '\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u65e2\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002',\n        ],\n    ],\n];<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30ed\u30b1\u30fc\u30eb\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ AppServiceProvider\u3067\u8a2d\u5b9a\npublic function boot()\n{\n    \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30ed\u30b1\u30fc\u30eb\u3092\u8a2d\u5b9a\n    App::setLocale('ja');\n\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u9078\u629e\u306b\u57fa\u3065\u3044\u3066\u30ed\u30b1\u30fc\u30eb\u3092\u52d5\u7684\u306b\u8a2d\u5b9a\n    if (Session::has('locale')) {\n        App::setLocale(Session::get('locale'));\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u306e\u30ab\u30b9\u30bf\u30e0\u30e1\u30c3\u30bb\u30fc\u30b8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass UserRegistrationRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'name' =&gt; 'required|string|max:255',\n            'email' =&gt; 'required|email|unique:users',\n            'password' =&gt; 'required|min:8|confirmed',\n        ];\n    }\n\n    public function attributes()\n    {\n        return [\n            'name' =&gt; __('validation.attributes.name'),\n            'email' =&gt; __('validation.attributes.email'),\n            'password' =&gt; __('validation.attributes.password'),\n        ];\n    }\n\n    public function messages()\n    {\n        return [\n            'email.unique' =&gt; __('validation.custom.email.unique'),\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u52d5\u7684\u306a\u5909\u66f4<\/h3>\n\n\n\n<p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u52d5\u7684\u306b\u5909\u66f4\u3059\u308b\u65b9\u6cd5\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u57fa\u3065\u304f\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Illuminate\\Support\\Facades\\Validator;\n\n$validator = Validator::make($request-&gt;all(), [\n    'age' =&gt; 'required|integer|min:18',\n], [\n    'age.min' =&gt; function ($message, $attribute, $rule, $parameters) {\n        $minimumAge = $parameters[0];\n        return \"\u7533\u3057\u8a33\u3042\u308a\u307e\u305b\u3093\u304c\u3001{$minimumAge}\u6b73\u672a\u6e80\u306e\u65b9\u306f\u767b\u9332\u3067\u304d\u307e\u305b\u3093\u3002\";\n    }\n]);<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u6761\u4ef6\u306b\u57fa\u3065\u304f\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u5207\u308a\u66ff\u3048<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function messages()\n{\n    $messages = [\n        'title.required' =&gt; ':attribute\u306f\u5fc5\u9808\u3067\u3059\u3002',\n        'content.min' =&gt; ':attribute\u306f\u6700\u4f4e:min\u6587\u5b57\u5fc5\u8981\u3067\u3059\u3002',\n    ];\n\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u5f79\u5272\u306b\u57fa\u3065\u3044\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5909\u66f4\n    if (auth()-&gt;user()-&gt;isAdmin()) {\n        $messages['title.required'] = '\u7ba1\u7406\u8005\u306f\u5fc5\u305a\u30bf\u30a4\u30c8\u30eb\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002';\n    }\n\n    return $messages;\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u52d5\u7684\u306a\u7f6e\u63db\u3092\u542b\u3080\u30e1\u30c3\u30bb\u30fc\u30b8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules;\n\nuse Illuminate\\Contracts\\Validation\\Rule;\n\nclass StrongPassword implements Rule\n{\n    private $requirements = [];\n\n    public function passes($attribute, $value)\n    {\n        if (!preg_match('\/[A-Z]\/', $value)) {\n            $this-&gt;requirements[] = '\u5927\u6587\u5b57';\n        }\n        if (!preg_match('\/[a-z]\/', $value)) {\n            $this-&gt;requirements[] = '\u5c0f\u6587\u5b57';\n        }\n        if (!preg_match('\/[0-9]\/', $value)) {\n            $this-&gt;requirements[] = '\u6570\u5b57';\n        }\n        if (!preg_match('\/[!@#$%^&amp;*]\/', $value)) {\n            $this-&gt;requirements[] = '\u7279\u6b8a\u6587\u5b57';\n        }\n\n        return empty($this-&gt;requirements);\n    }\n\n    public function message()\n    {\n        return '\u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u306f' . implode('\u3001', $this-&gt;requirements) . '\u304c\u5fc5\u8981\u3067\u3059\u3002';\n    }\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u306e\u8868\u793a\u65b9\u6cd5<\/strong><\/li>\n<\/ol>\n\n\n\n<p>Blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u306e\u30a8\u30e9\u30fc\u8868\u793a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@if ($errors-&gt;any())\n    &lt;div class=\"alert alert-danger\"&gt;\n        &lt;ul&gt;\n            @foreach ($errors-&gt;all() as $error)\n                &lt;li&gt;{{ $error }}&lt;\/li&gt;\n            @endforeach\n        &lt;\/ul&gt;\n    &lt;\/div&gt;\n@endif\n\n\/\/ \u7279\u5b9a\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30a8\u30e9\u30fc\u8868\u793a\n@error('email')\n    &lt;div class=\"alert alert-danger\"&gt;{{ $message }}&lt;\/div&gt;\n@enderror<\/pre>\n\n\n\n<p>API\u30ec\u30b9\u30dd\u30f3\u30b9\u3067\u306e\u30a8\u30e9\u30fc\u8868\u793a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function store(UserRegistrationRequest $request)\n{\n    try {\n        \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\n    } catch (ValidationException $e) {\n        return response()-&gt;json([\n            'message' =&gt; '\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n            'errors' =&gt; $e-&gt;errors(),\n        ], 422);\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u65b9\u6cd5\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u30d5\u30ec\u30f3\u30c9\u30ea\u30fc\u3067\u5206\u304b\u308a\u3084\u3059\u3044\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u591a\u8a00\u8a9e\u5bfe\u5fdc\u306b\u3088\u308a\u3001\u56fd\u969b\u7684\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u306b\u3082\u5bfe\u5fdc\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-14\">\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b97\u9078<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">1. \u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u9069\u5207\u306a\u4f7f\u7528<\/h3>\n\n\n\n<p>\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3001\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u6574\u7406\u3057\u3001\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u6027\u3092\u9ad8\u3081\u308b\u305f\u3081\u306e\u91cd\u8981\u306a\u624b\u6bb5\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass UpdateProductRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'name' =&gt; ['required', 'string', 'max:255'],\n            'price' =&gt; ['required', 'numeric', 'min:0'],\n            'category_id' =&gt; ['required', 'exists:categories,id'],\n            'status' =&gt; ['required', Rule::in(['draft', 'published', 'archived'])],\n            'tags' =&gt; ['array', 'max:5'],\n            'tags.*' =&gt; ['exists:tags,id']\n        ];\n    }\n\n    \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u524d\u306e\u5165\u529b\u30c7\u30fc\u30bf\u306e\u52a0\u5de5\n    protected function prepareForValidation()\n    {\n        if ($this-&gt;has('tags')) {\n            $this-&gt;merge([\n                'tags' =&gt; array_unique($this-&gt;tags)\n            ]);\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">2. \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u518d\u5229\u7528<\/h3>\n\n\n\n<p>\u5171\u901a\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306f\u3001\u72ec\u7acb\u3057\u305f\u30af\u30e9\u30b9\u3084\u30c8\u30ec\u30a4\u30c8\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u91cd\u8907\u3092\u9632\u304e\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules\\Traits;\n\ntrait AddressValidationRules\n{\n    protected function getAddressRules(): array\n    {\n        return [\n            'postal_code' =&gt; ['required', 'string', new PostalCode],\n            'prefecture' =&gt; ['required', 'string', Rule::in($this-&gt;getPrefectures())],\n            'city' =&gt; ['required', 'string', 'max:255'],\n            'street' =&gt; ['required', 'string', 'max:255'],\n            'building' =&gt; ['nullable', 'string', 'max:255']\n        ];\n    }\n\n    private function getPrefectures(): array\n    {\n        return config('address.prefectures');\n    }\n}<\/pre>\n\n\n\n<p>\u4f7f\u7528\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CustomerRequest extends FormRequest\n{\n    use AddressValidationRules;\n\n    public function rules()\n    {\n        return array_merge([\n            'name' =&gt; 'required|string|max:255',\n            'email' =&gt; 'required|email|unique:customers'\n        ], $this-&gt;getAddressRules());\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">3. \u30bb\u30ad\u30e5\u30a2\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u8a08<\/h3>\n\n\n\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8003\u616e\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u8a08\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5805\u7262\u6027\u3092\u9ad8\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Support\\Facades\\Hash;\n\nclass ChangePasswordRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'current_password' =&gt; [\n                'required',\n                function ($attribute, $value, $fail) {\n                    if (!Hash::check($value, auth()-&gt;user()-&gt;password)) {\n                        $fail('\u73fe\u5728\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002');\n                    }\n                }\n            ],\n            'password' =&gt; [\n                'required',\n                'string',\n                'min:8',\n                'confirmed',\n                'different:current_password',\n                new StrongPassword, \/\/ \u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30eb\n                function ($attribute, $value, $fail) {\n                    \/\/ \u30d1\u30b9\u30ef\u30fc\u30c9\u5c65\u6b74\u30c1\u30a7\u30c3\u30af\n                    if ($this-&gt;isPasswordPreviouslyUsed($value)) {\n                        $fail('\u3053\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u904e\u53bb\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002');\n                    }\n                }\n            ]\n        ];\n    }\n\n    protected function isPasswordPreviouslyUsed($password)\n    {\n        return auth()-&gt;user()\n            -&gt;passwordHistory()\n            -&gt;whereIn('password', [Hash::make($password)])\n            -&gt;exists();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">4. \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u30eb\u30fc\u30eb\u8a2d\u8a08<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u9069\u5316\u3059\u308b\u3053\u3068\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5168\u4f53\u306e\u5fdc\u7b54\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Cache\\RateLimiter;\n\nclass BulkOperationRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'items' =&gt; ['required', 'array', 'max:1000'], \/\/ \u4e00\u5ea6\u306b\u51e6\u7406\u3059\u308b\u4ef6\u6570\u3092\u5236\u9650\n            'items.*.id' =&gt; [\n                'required',\n                'integer',\n                \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30af\u30a8\u30ea\u3092\u6700\u9069\u5316\n                Rule::exists('items', 'id')-&gt;where(function ($query) {\n                    $query-&gt;select('id')-&gt;whereNull('deleted_at');\n                })\n            ]\n        ];\n    }\n\n    public function withValidator($validator)\n    {\n        \/\/ \u30ec\u30fc\u30c8\u30ea\u30df\u30c3\u30c8\u306e\u5b9f\u88c5\n        $limiter = app(RateLimiter::class);\n\n        if ($limiter-&gt;tooManyAttempts($this-&gt;ip(), 60)) {\n            abort(429, 'Too many requests.');\n        }\n\n        $limiter-&gt;hit($this-&gt;ip(), 60);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">5. \u30c6\u30b9\u30c8\u53ef\u80fd\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306f\u3001\u9069\u5207\u306b\u30c6\u30b9\u30c8\u53ef\u80fd\u306a\u5f62\u3067\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace Tests\\Unit\\Requests;\n\nuse Tests\\TestCase;\nuse App\\Http\\Requests\\UpdateProductRequest;\nuse Illuminate\\Support\\Facades\\Validator;\n\nclass UpdateProductRequestTest extends TestCase\n{\n    private $request;\n\n    protected function setUp(): void\n    {\n        parent::setUp();\n        $this-&gt;request = new UpdateProductRequest();\n    }\n\n    \/** @test *\/\n    public function it_validates_product_name()\n    {\n        $validator = Validator::make([\n            'name' =&gt; 'Test Product',\n            'price' =&gt; 1000,\n            'category_id' =&gt; 1\n        ], $this-&gt;request-&gt;rules());\n\n        $this-&gt;assertTrue($validator-&gt;passes());\n    }\n\n    \/** @test *\/\n    public function it_validates_price_is_not_negative()\n    {\n        $validator = Validator::make([\n            'name' =&gt; 'Test Product',\n            'price' =&gt; -1000,\n            'category_id' =&gt; 1\n        ], $this-&gt;request-&gt;rules());\n\n        $this-&gt;assertTrue($validator-&gt;fails());\n        $this-&gt;assertArrayHasKey('price', $validator-&gt;errors()-&gt;toArray());\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">6. \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u6700\u9069\u5316<\/h3>\n\n\n\n<p>\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Exceptions;\n\nuse Illuminate\\Foundation\\Exceptions\\Handler as ExceptionHandler;\nuse Illuminate\\Validation\\ValidationException;\nuse Throwable;\n\nclass Handler extends ExceptionHandler\n{\n    protected function convertValidationExceptionToResponse(ValidationException $e, $request)\n    {\n        if ($request-&gt;expectsJson()) {\n            return response()-&gt;json([\n                'message' =&gt; '\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n                'errors' =&gt; $this-&gt;formatValidationErrors($e-&gt;validator),\n            ], 422);\n        }\n\n        return redirect()\n            -&gt;back()\n            -&gt;withInput()\n            -&gt;withErrors($e-&gt;errors(), $e-&gt;errorBag);\n    }\n\n    protected function formatValidationErrors($validator)\n    {\n        $errors = $validator-&gt;errors()-&gt;toArray();\n\n        return collect($errors)-&gt;map(function ($messages, $field) {\n            return [\n                'field' =&gt; $field,\n                'messages' =&gt; $messages,\n                'value' =&gt; request()-&gt;input($field)\n            ];\n        })-&gt;values()-&gt;all();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">7. \u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08<\/h3>\n\n\n\n<p>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u9ad8\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u8a08\u306b\u3088\u308a\u3001\u5c06\u6765\u7684\u306a\u5909\u66f4\u3084\u62e1\u5f35\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Rules;\n\nclass ValidationRuleSet\n{\n    private static $rules = [];\n\n    public static function register(string $key, array $rules): void\n    {\n        static::$rules[$key] = $rules;\n    }\n\n    public static function get(string $key): array\n    {\n        return static::$rules[$key] ?? [];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nValidationRuleSet::register('user.create', [\n    'name' =&gt; ['required', 'string', 'max:255'],\n    'email' =&gt; ['required', 'email', 'unique:users'],\n    'password' =&gt; ['required', 'min:8', 'confirmed']\n]);\n\nValidationRuleSet::register('user.update', [\n    'name' =&gt; ['sometimes', 'required', 'string', 'max:255'],\n    'email' =&gt; ['sometimes', 'required', 'email', Rule::unique('users')-&gt;ignore($userId)]\n]);\n\n\/\/ \u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u306e\u4f7f\u7528\nclass CreateUserRequest extends FormRequest\n{\n    public function rules()\n    {\n        return ValidationRuleSet::get('user.create');\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u4fdd\u5b88\u6027\u304c\u9ad8\u304f\u3001\u30bb\u30ad\u30e5\u30a2\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u826f\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u3053\u308c\u3089\u306e\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u898f\u6a21\u3084\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u9069\u5207\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-22\">\u5b9f\u8df5\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306f\u3001\u591a\u304f\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u5fc5\u8981\u3068\u306a\u308b\u57fa\u672c\u7684\u306a\u6a5f\u80fd\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30e6\u30fc\u30b6\u30d3\u30ea\u30c6\u30a3\u3092\u8003\u616e\u3057\u305f\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rules\\Password;\nuse App\\Rules\\ValidUsername;\n\nclass UserRegistrationRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'username' =&gt; [\n                'required',\n                'string',\n                'min:3',\n                'max:20',\n                'unique:users',\n                new ValidUsername,\n            ],\n            'email' =&gt; [\n                'required',\n                'string',\n                'email',\n                'max:255',\n                'unique:users',\n                'not_regex:\/^(admin|support|info|contact)@\/',\n            ],\n            'password' =&gt; [\n                'required',\n                'confirmed',\n                Password::min(8)\n                    -&gt;letters()\n                    -&gt;mixedCase()\n                    -&gt;numbers()\n                    -&gt;symbols()\n                    -&gt;uncompromised(),\n            ],\n            'terms' =&gt; ['required', 'accepted'],\n            'profile' =&gt; ['nullable', 'array'],\n            'profile.birth_date' =&gt; [\n                'nullable',\n                'date',\n                'before:today',\n                'after:1900-01-01'\n            ],\n            'profile.phone' =&gt; [\n                'nullable',\n                'string',\n                'regex:\/^([0-9\\s\\-\\+\\(\\)]*)$\/',\n                'min:10'\n            ]\n        ];\n    }\n\n    public function messages()\n    {\n        return [\n            'password.uncompromised' =&gt; '\u3053\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u6f0f\u6d29\u3057\u305f\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002',\n            'email.not_regex' =&gt; '\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002',\n            'profile.birth_date.before' =&gt; '\u751f\u5e74\u6708\u65e5\u306f\u4eca\u65e5\u3088\u308a\u524d\u306e\u65e5\u4ed8\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002',\n            'profile.birth_date.after' =&gt; '\u6b63\u3057\u3044\u751f\u5e74\u6708\u65e5\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002'\n        ];\n    }\n\n    protected function prepareForValidation()\n    {\n        \/\/ \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u6b63\u898f\u5316\n        if ($this-&gt;has('email')) {\n            $this-&gt;merge([\n                'email' =&gt; strtolower($this-&gt;email)\n            ]);\n        }\n\n        \/\/ \u96fb\u8a71\u756a\u53f7\u306e\u6b63\u898f\u5316\n        if ($this-&gt;has('profile.phone')) {\n            $this-&gt;merge([\n                'profile' =&gt; array_merge($this-&gt;profile ?? [], [\n                    'phone' =&gt; preg_replace('\/[^0-9]\/', '', $this-&gt;input('profile.phone'))\n                ])\n            ]);\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306b\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u4e21\u9762\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Support\\Facades\\Storage;\n\nclass DocumentUploadRequest extends FormRequest\n{\n    public function rules()\n    {\n        return [\n            'documents' =&gt; [\n                'required',\n                'array',\n                'max:5' \/\/ \u6700\u59275\u30d5\u30a1\u30a4\u30eb\u307e\u3067\n            ],\n            'documents.*' =&gt; [\n                'required',\n                'file',\n                'mimes:pdf,doc,docx,xls,xlsx',\n                'max:10240', \/\/ 10MB\u5236\u9650\n                function ($attribute, $value, $fail) {\n                    \/\/ \u30a6\u30a4\u30eb\u30b9\u30b9\u30ad\u30e3\u30f3\u306e\u30e2\u30c3\u30af\n                    if (!$this-&gt;scanFile($value)) {\n                        $fail('\u30d5\u30a1\u30a4\u30eb\u306e\u5b89\u5168\u6027\u304c\u78ba\u8a8d\u3067\u304d\u307e\u305b\u3093\u3002');\n                    }\n                }\n            ],\n            'category' =&gt; 'required|string|in:contract,report,invoice',\n            'description' =&gt; 'nullable|string|max:1000'\n        ];\n    }\n\n    protected function scanFile($file)\n    {\n        \/\/ \u5b9f\u969b\u306e\u30a6\u30a4\u30eb\u30b9\u30b9\u30ad\u30e3\u30f3\u51e6\u7406\u3092\u3053\u3053\u306b\u5b9f\u88c5\n        return true;\n    }\n\n    public function withValidator($validator)\n    {\n        $validator-&gt;after(function ($validator) {\n            $totalSize = collect($this-&gt;file('documents'))\n                -&gt;sum(function ($file) {\n                    return $file-&gt;getSize();\n                });\n\n            \/\/ \u5408\u8a08\u30b5\u30a4\u30ba\u30c1\u30a7\u30c3\u30af\uff0830MB\u5236\u9650\uff09\n            if ($totalSize &gt; 30 * 1024 * 1024) {\n                $validator-&gt;errors()-&gt;add(\n                    'documents',\n                    '\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u5408\u8a08\u30b5\u30a4\u30ba\u304c\u5236\u9650\u3092\u8d85\u3048\u3066\u3044\u307e\u3059\u3002'\n                );\n            }\n        });\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">API \u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>API\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u9069\u5207\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u5f62\u5f0f\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Contracts\\Validation\\Validator;\nuse Illuminate\\Http\\Exceptions\\HttpResponseException;\n\nclass ApiProductRequest extends FormRequest\n{\n    public function rules()\n    {\n        $method = $this-&gt;method();\n\n        $rules = [\n            'name' =&gt; ['required', 'string', 'max:255'],\n            'price' =&gt; ['required', 'numeric', 'min:0'],\n            'category_id' =&gt; ['required', 'exists:categories,id'],\n            'description' =&gt; ['nullable', 'string'],\n            'attributes' =&gt; ['required', 'array'],\n            'attributes.*.key' =&gt; ['required', 'string'],\n            'attributes.*.value' =&gt; ['required', 'string'],\n            'tags' =&gt; ['array'],\n            'tags.*' =&gt; ['exists:tags,id'],\n            'status' =&gt; ['required', 'in:draft,active,archived']\n        ];\n\n        if ($method === 'PATCH') {\n            return array_map(function ($rule) {\n                return array_merge(['sometimes'], (array)$rule);\n            }, $rules);\n        }\n\n        return $rules;\n    }\n\n    protected function failedValidation(Validator $validator)\n    {\n        throw new HttpResponseException(response()-&gt;json([\n            'status' =&gt; 'error',\n            'message' =&gt; '\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n            'errors' =&gt; $this-&gt;formatErrors($validator),\n            'error_code' =&gt; 'VALIDATION_ERROR'\n        ], 422));\n    }\n\n    protected function formatErrors(Validator $validator)\n    {\n        return collect($validator-&gt;errors())-&gt;map(function ($messages, $field) {\n            return [\n                'field' =&gt; $field,\n                'messages' =&gt; $messages,\n                'received_value' =&gt; $this-&gt;input($field)\n            ];\n        })-&gt;values();\n    }\n\n    public function withValidator($validator)\n    {\n        \/\/ API\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ec\u30fc\u30c8\u5236\u9650\u30c1\u30a7\u30c3\u30af\n        $validator-&gt;after(function ($validator) {\n            if ($this-&gt;exceedsRateLimit()) {\n                $validator-&gt;errors()-&gt;add(\n                    'api',\n                    'API\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5236\u9650\u3092\u8d85\u3048\u307e\u3057\u305f\u3002\u3057\u3070\u3089\u304f\u5f85\u3063\u3066\u304b\u3089\u518d\u8a66\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002'\n                );\n            }\n        });\n    }\n\n    protected function exceedsRateLimit()\n    {\n        \/\/ \u30ec\u30fc\u30c8\u5236\u9650\u306e\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\n        return false;\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3050\u306b\u6d3b\u7528\u3067\u304d\u308b\u5f62\u3067\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u5404\u5b9f\u88c5\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u91cd\u8981\u306a\u8981\u7d20\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u306e\u6b63\u898f\u5316<\/strong>\uff1a\u5165\u529b\u30c7\u30fc\u30bf\u3092\u4e00\u8cab\u3057\u305f\u5f62\u5f0f\u306b\u5909\u63db<\/li>\n\n\n\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56<\/strong>\uff1a\u4e0d\u6b63\u306a\u30c7\u30fc\u30bf\u3084\u30d5\u30a1\u30a4\u30eb\u306e\u691c\u51fa\u3068\u9632\u6b62<\/li>\n\n\n\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8003\u616e<\/strong>\uff1a\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u5236\u9650\u3084\u30ec\u30fc\u30c8\u5236\u9650\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li><strong>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/strong>\uff1a\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u5f62\u5f0f<\/li>\n\n\n\n<li><strong>\u67d4\u8edf\u6027<\/strong>\uff1aHTTP \u30e1\u30bd\u30c3\u30c9\u306b\u5fdc\u3058\u305f\u30eb\u30fc\u30eb\u306e\u52d5\u7684\u306a\u8abf\u6574<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u3092\u57fa\u306b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8981\u4ef6\u306b\u5408\u308f\u305b\u3066\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u3067\u3001\u5805\u7262\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-26\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-28\">1. \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u304c\u6b63\u3057\u304f\u9069\u7528\u3055\u308c\u306a\u3044<\/h4>\n\n\n\n<p><strong>\u554f\u984c\u306e\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'email' =&gt; 'required|email|unique:users'\n    'age' =&gt; 'required|integer|min:18'  \/\/ \u30ab\u30f3\u30de\u304c\u629c\u3051\u3066\u3044\u308b\n];<\/pre>\n\n\n\n<p><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$rules = [\n    'email' =&gt; 'required|email|unique:users',\n    'age' =&gt; 'required|integer|min:18'\n];\n\n\/\/ \u307e\u305f\u306f\u914d\u5217\u8a18\u6cd5\u3092\u4f7f\u7528\uff08\u63a8\u5968\uff09\n$rules = [\n    'email' =&gt; ['required', 'email', 'unique:users'],\n    'age' =&gt; ['required', 'integer', 'min:18']\n];<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-29\">2. \u30cd\u30b9\u30c8\u3055\u308c\u305f\u914d\u5217\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc<\/h4>\n\n\n\n<p><strong>\u554f\u984c\u306e\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u6b63\u3057\u304f\u691c\u8a3c\u3067\u304d\u306a\u3044\n$rules = [\n    'users.*.email' =&gt; 'required|email',\n    'users.*.profile.phone' =&gt; 'required|string'\n];<\/pre>\n\n\n\n<p><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function rules()\n{\n    return [\n        'users' =&gt; ['required', 'array'],\n        'users.*.email' =&gt; ['required', 'email'],\n        'users.*.profile' =&gt; ['required', 'array'],\n        'users.*.profile.phone' =&gt; ['required', 'string']\n    ];\n}\n\nprotected function prepareForValidation()\n{\n    \/\/ \u30cd\u30b9\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306e\u5b58\u5728\u78ba\u8a8d\n    $users = $this-&gt;input('users', []);\n    foreach ($users as $key =&gt; $user) {\n        if (!isset($user['profile'])) {\n            $users[$key]['profile'] = [];\n        }\n    }\n    $this-&gt;merge(['users' =&gt; $users]);\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-30\">3. unique\u30eb\u30fc\u30eb\u3067\u306e\u66f4\u65b0\u6642\u306e\u554f\u984c<\/h4>\n\n\n\n<p><strong>\u554f\u984c\u306e\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u81ea\u5206\u81ea\u8eab\u306e\u30ec\u30b3\u30fc\u30c9\u3067\u30e6\u30cb\u30fc\u30af\u5236\u7d04\u30a8\u30e9\u30fc\u304c\u767a\u751f\n'email' =&gt; 'required|email|unique:users'<\/pre>\n\n\n\n<p><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Illuminate\\Validation\\Rule;\n\npublic function rules()\n{\n    return [\n        'email' =&gt; [\n            'required',\n            'email',\n            Rule::unique('users')-&gt;ignore($this-&gt;user-&gt;id)\n        ]\n    ];\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-31\">4. \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u306a\u3044<\/h4>\n\n\n\n<p><strong>\u554f\u984c\u306e\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\npublic function messages()\n{\n    return [\n        'email.unique' =&gt; '\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u65e2\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002'\n    ];\n}<\/pre>\n\n\n\n<p><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function messages()\n{\n    return [\n        'email.unique' =&gt; '\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u65e2\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002'\n    ];\n}\n\n\/\/ \u307e\u305f\u306f\u3001\u5c5e\u6027\u540d\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\npublic function attributes()\n{\n    return [\n        'email' =&gt; '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9'\n    ];\n}\n\n\/\/ \u307e\u305f\u306f\u3001\u8a00\u8a9e\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\n\/\/ resources\/lang\/ja\/validation.php\nreturn [\n    'custom' =&gt; [\n        'email' =&gt; [\n            'unique' =&gt; '\u3053\u306e:attribute\u306f\u65e2\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002'\n        ]\n    ],\n    'attributes' =&gt; [\n        'email' =&gt; '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9'\n    ]\n];<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-32\">\u30c7\u30d0\u30c3\u30b0\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-33\">1. \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u30c7\u30d0\u30c3\u30b0<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Illuminate\\Support\\Facades\\Validator;\n\n\/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u3092\u30c7\u30d0\u30c3\u30b0\n$validator = Validator::make($request-&gt;all(), $rules);\n\n\/\/ \u5931\u6557\u3057\u305f\u30eb\u30fc\u30eb\u306e\u8a73\u7d30\u3092\u78ba\u8a8d\n$validator-&gt;fails(); \/\/ true\/false\ndd($validator-&gt;failed()); \/\/ \u5931\u6557\u3057\u305f\u30eb\u30fc\u30eb\u306e\u8a73\u7d30\u3092\u8868\u793a\n\n\/\/ \u73fe\u5728\u306e\u5165\u529b\u5024\u3092\u78ba\u8a8d\ndd($validator-&gt;getData());\n\n\/\/ \u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u78ba\u8a8d\ndd($validator-&gt;errors()-&gt;toArray());<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-34\">2. \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30d0\u30c3\u30b0<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CustomRule implements Rule\n{\n    public function passes($attribute, $value)\n    {\n        \\Log::debug('Validating ' . $attribute . ' with value: ' . $value);\n\n        \/\/ \u30c7\u30d0\u30c3\u30b0\u7528\u306e\u4e2d\u9593\u72b6\u614b\u3092\u8a18\u9332\n        $result = $this-&gt;validateValue($value);\n        \\Log::debug('Validation result: ' . ($result ? 'true' : 'false'));\n\n        return $result;\n    }\n\n    private function validateValue($value)\n    {\n        \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n        return true;\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-35\">3. \u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30c7\u30d0\u30c3\u30b0<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class UserRequest extends FormRequest\n{\n    public function rules()\n    {\n        \\Log::debug('Request data:', $this-&gt;all());\n        \\Log::debug('Current route:', [\n            'name' =&gt; $this-&gt;route()-&gt;getName(),\n            'parameters' =&gt; $this-&gt;route()-&gt;parameters()\n        ]);\n\n        return [\n            'name' =&gt; 'required|string'\n        ];\n    }\n\n    protected function failedValidation(Validator $validator)\n    {\n        \\Log::debug('Validation failed:', [\n            'errors' =&gt; $validator-&gt;errors()-&gt;toArray(),\n            'input' =&gt; $this-&gt;all()\n        ]);\n\n        parent::failedValidation($validator);\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-36\">4. \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5206\u6790<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Illuminate\\Support\\Facades\\DB;\n\nclass ComplexValidationRequest extends FormRequest\n{\n    public function rules()\n    {\n        DB::enableQueryLog();\n\n        $rules = [\n            'user_id' =&gt; [\n                'required',\n                'exists:users,id',\n                function ($attribute, $value, $fail) {\n                    \/\/ \u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n                }\n            ]\n        ];\n\n        \/\/ \u30af\u30a8\u30ea\u30ed\u30b0\u3092\u78ba\u8a8d\n        \\Log::debug('Validation queries:', DB::getQueryLog());\n\n        return $rules;\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-37\">5. \u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6bb5\u968e\u7684\u306a\u30c7\u30d0\u30c3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6700\u521d\u306b\u57fa\u672c\u7684\u306a\u30eb\u30fc\u30eb\u306e\u307f\u3067\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u5f90\u3005\u306b\u8907\u96d1\u306a\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6642\u70b9\u3067\u539f\u56e0\u3092\u7279\u5b9a<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u6d3b\u7528<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function withValidator($validator)\n{\n    $validator-&gt;after(function ($validator) {\n        if ($validator-&gt;errors()-&gt;isNotEmpty()) {\n            \\Log::error('Validation failed', [\n                'input' =&gt; $this-&gt;all(),\n                'errors' =&gt; $validator-&gt;errors()-&gt;toArray()\n            ]);\n        }\n    });\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u4f5c\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace Tests\\Unit\\Requests;\n\nuse Tests\\TestCase;\nuse App\\Http\\Requests\\UserRequest;\n\nclass UserRequestTest extends TestCase\n{\n    \/** @test *\/\n    public function it_fails_validation_with_invalid_data()\n    {\n        $request = new UserRequest();\n        $request-&gt;replace([\n            'email' =&gt; 'invalid-email'\n        ]);\n\n        $validator = app('validator')-&gt;make(\n            $request-&gt;all(),\n            $request-&gt;rules()\n        );\n\n        $this-&gt;assertTrue($validator-&gt;fails());\n        $this-&gt;assertArrayHasKey('email', $validator-&gt;errors()-&gt;toArray());\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u6280\u6cd5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306b\u95a2\u3059\u308b\u554f\u984c\u3092\u52b9\u7387\u7684\u306b\u7279\u5b9a\u3057\u3001\u89e3\u6c7a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u30c7\u30d0\u30c3\u30b0\u904e\u7a0b\u3067\u5f97\u3089\u308c\u305f\u77e5\u898b\u3092\u3001\u3088\u308a\u5805\u7262\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u306b\u6d3b\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,12],"tags":[],"class_list":{"0":"post-3243","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php-laravel","7":"category-php","8":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3243"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3243\/revisions"}],"predecessor-version":[{"id":3245,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3243\/revisions\/3245"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}