{"id":306,"date":"2025-03-24T08:54:53","date_gmt":"2025-03-23T23:54:53","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=306"},"modified":"2025-03-24T08:54:53","modified_gmt":"2025-03-23T23:54:53","slug":"%e3%80%902024%e5%b9%b4%e6%9c%80%e6%96%b0%e3%80%91spring-framework-validation%e3%83%9e%e3%82%b9%e3%82%bf%e3%83%bc%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%8a%b9%e7%8e%87%e7%9a%84%e3%81%aa%e5%ae%9f","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=306","title":{"rendered":"\u30102024\u5e74\u6700\u65b0\u3011Spring Framework Validation\u30de\u30b9\u30bf\u30fc\u30ac\u30a4\u30c9\uff1a\u52b9\u7387\u7684\u306a\u5b9f\u88c5\u304b\u3089\u5fdc\u7528\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067"},"content":{"rendered":"\n<p>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3068\u4fe1\u983c\u6027\u306f\u3001\u73fe\u4ee3\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\u3002Spring Framework\u306f\u3001\u3053\u306e\u8ab2\u984c\u306b\u5bfe\u3057\u3066\u5f37\u529b\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001Spring Framework Validation\u306e\u57fa\u790e\u304b\u3089\u5fdc\u7528\u307e\u3067\u3001\u5305\u62ec\u7684\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Spring Framework 6.1\uff082024\u5e74\u73fe\u5728\u306e\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\uff09\u3067\u306f\u3001\u3088\u308a\u67d4\u8edf\u3067\u52b9\u7387\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u304c\u5c0e\u5165\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u901a\u3058\u3066\u3001\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u5b66\u3076\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Spring Framework Validation\u306e\u57fa\u672c\u6982\u5ff5\u3068\u91cd\u8981\u6027<\/li>\n\n\n\n<li>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a\u304b\u3089\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5\u307e\u3067<\/li>\n\n\n\n<li>RESTful API\u306b\u304a\u3051\u308b\u6700\u9069\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3068\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3068\u306e\u7d71\u5408\u65b9\u6cd5<\/li>\n\n\n\n<li>\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u6700\u65b0\u30c8\u30ec\u30f3\u30c9<\/li>\n<\/ol>\n\n\n\n<p>\u521d\u5fc3\u8005\u304b\u3089\u4e2d\u7d1a\u8005\u307e\u3067\u3001Spring Framework Validation\u306e\u30b9\u30ad\u30eb\u3092\u4e00\u6bb5\u968e\u4e0a\u3052\u305f\u3044\u958b\u767a\u8005\u306e\u7686\u69d8\u306b\u3001\u5b9f\u8df5\u7684\u3067\u4fa1\u5024\u3042\u308b\u60c5\u5831\u3092\u304a\u5c4a\u3051\u3057\u307e\u3059\u3002\u305c\u3072\u6700\u5f8c\u307e\u3067\u304a\u4ed8\u304d\u5408\u3044\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\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\">1. Spring Framework Validation\u306e\u57fa\u790e<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">1.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027\u3068Spring Framework\u306e\u5f79\u5272<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">1.2 Spring Validation\u306e\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u89e3\u8aac<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">2. Spring Validation\u306e\u57fa\u672c\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">2.1 \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-5\">2.2 \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u4f5c\u6210\u624b\u9806<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-6\">3. Spring Validation\u306e\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-7\">3.1 \u30b0\u30eb\u30fc\u30d7\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u6d3b\u7528\u30b7\u30ca\u30ea\u30aa\u3068\u5b9f\u88c5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">3.2 \u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u73fe\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">4. RESTful API\u306b\u304a\u3051\u308bSpring Validation\u306e\u6700\u9069\u306a\u5229\u7528\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">4.1 \u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li>        <a href=\"#i-11\">4.2 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-12\">\u30d1\u30b9\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-13\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u9762\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8003\u616e\u4e8b\u9805<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-15\">5. Spring Validation\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">5.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u306e\u52b9\u7387\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li>        <a href=\"#i-17\">5.2 \u5927\u898f\u6a21\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-18\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-19\">6. Spring Validation\u3068\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-20\">6.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u624b\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-21\">6.2 \u30e2\u30c3\u30af\u3092\u6d3b\u7528\u3057\u305f\u7d71\u5408\u30c6\u30b9\u30c8\u306e\u5b9f\u88c5\u4f8b<\/a>      <\/li>      <li>        <a href=\"#i-22\">TDD\u3092\u7528\u3044\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u958b\u767a\u30d7\u30ed\u30bb\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-23\">\u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u3068\u5883\u754c\u5024\u30c6\u30b9\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-24\">\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-25\">7. Spring Validation\u306e\u5b9f\u8df5\u7684\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-26\">7.1 \u30d5\u30a9\u30fc\u30e0\u9001\u4fe1\u6642\u306e\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-27\">7.2 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u9023\u643a\u6642\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u306e\u7d44\u307f\u8fbc\u307f\u65b9<\/a>      <\/li>      <li>        <a href=\"#i-28\">\u8907\u96d1\u306a\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306b\u57fa\u3065\u304f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-29\">\u591a\u8a00\u8a9e\u5bfe\u5fdc\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30e1\u30c3\u30bb\u30fc\u30b8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-30\">\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-31\">8. Spring Validation\u306e\u6700\u65b0\u30c8\u30ec\u30f3\u30c9\u3068\u4eca\u5f8c\u306e\u5c55\u671b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-32\">8.1 Jakarta Bean Validation\u3068\u306e\u7d71\u5408\u52d5\u5411<\/a>      <\/li>      <li>        <a href=\"#i-33\">8.2 \u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u304a\u3051\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/a>      <\/li>      <li>        <a href=\"#i-34\">\u65b0\u3057\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6280\u8853\u3068\u624b\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-35\">Spring Framework 6.0\u306e\u65b0\u6a5f\u80fd<\/a>      <\/li>      <li>        <a href=\"#i-36\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u7d71\u5408<\/a>      <\/li>      <li>        <a href=\"#i-37\">AI\/\u6a5f\u68b0\u5b66\u7fd2\u3092\u6d3b\u7528\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-38\">\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306e\u52d5\u5411<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-39\">\u307e\u3068\u3081<\/a>  <\/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\">1. Spring Framework Validation\u306e\u57fa\u790e<\/h2>\n\n\n\n<p>Spring Framework Validation\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30fc\u30bf\u6574\u5408\u6027\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306e\u5f37\u529b\u306a\u6a5f\u80fd\u30bb\u30c3\u30c8\u3067\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u305d\u306e\u57fa\u672c\u6982\u5ff5\u3068\u91cd\u8981\u6027\u3001\u305d\u3057\u3066\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">1.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027\u3068Spring Framework\u306e\u5f79\u5272<\/h3>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u4ee5\u4e0b\u306e\u7406\u7531\u304b\u3089\u73fe\u4ee3\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u304a\u3044\u3066\u6975\u3081\u3066\u91cd\u8981\u3067\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u5411\u4e0a<\/strong>: \u4e0d\u6b63\u306a\u30c7\u30fc\u30bf\u306e\u5165\u529b\u3092\u9632\u304e\u3001\u6f5c\u5728\u7684\u306a\u8106\u5f31\u6027\u3092\u8efd\u6e1b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c7\u30fc\u30bf\u6574\u5408\u6027\u306e\u78ba\u4fdd<\/strong>: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u306e\u4e00\u8cab\u6027\u3092\u7dad\u6301\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u306e\u6539\u5584<\/strong>: \u5373\u6642\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u64cd\u4f5c\u6027\u3092\u5411\u4e0a\u3055\u305b\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>Spring Framework\u306f\u3001\u3053\u308c\u3089\u306e\u8ab2\u984c\u306b\u5bfe\u3057\u3066\u5305\u62ec\u7684\u306a\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u5ba3\u8a00\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3001\u8c4a\u5bcc\u306a\u7d44\u307f\u8fbc\u307f\u30d0\u30ea\u30c7\u30fc\u30bf\u3001\u305d\u3057\u3066\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5bb9\u6613\u306a\u5b9f\u88c5\u306a\u3069\u3001\u958b\u767a\u8005\u304c\u52b9\u7387\u7684\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\u3067\u304d\u308b\u74b0\u5883\u3092\u6574\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">1.2 Spring Validation\u306e\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u89e3\u8aac<\/h3>\n\n\n\n<p>Spring Validation\u306f\u3001\u4ee5\u4e0b\u306e\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Bean Validation API<\/strong>: JSR 380\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u6a19\u6e96API\u3067\u3001\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/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 class User {\n    @NotNull(message = \"Name cannot be null\")\n    @Size(min = 2, max = 30, message = \"Name must be between 2 and 30 characters\")\n    private String name;\n\n    @Email(message = \"Email should be valid\")\n    private String email;\n\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Validator \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9<\/strong>: \u30d7\u30ed\u30b0\u30e9\u30e0\u7684\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u3059\u3002<\/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 class UserValidator implements Validator {\n    @Override\n    public boolean supports(Class&lt;?&gt; clazz) {\n        return User.class.equals(clazz);\n    }\n\n    @Override\n    public void validate(Object target, Errors errors) {\n        User user = (User) target;\n        if (user.getName().startsWith(\"Admin\")) {\n            errors.rejectValue(\"name\", \"name.reserved\", \"Name cannot start with 'Admin'\");\n        }\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>BindingResult \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>: \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u3092\u4fdd\u6301\u3057\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u7ba1\u7406\u3057\u307e\u3059\u3002<\/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=\"\">@PostMapping(\"\/user\")\npublic String createUser(@Valid @ModelAttribute User user, BindingResult result) {\n    if (result.hasErrors()) {\n        return \"userForm\";\n    }\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u51e6\u7406\n    return \"redirect:\/success\";\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>ValidationUtils \u30af\u30e9\u30b9<\/strong>: \u5171\u901a\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30bf\u30b9\u30af\u3092\u7c21\u7d20\u5316\u3059\u308b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u30af\u30e9\u30b9\u3067\u3059\u3002<\/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 void validate(Object target, Errors errors) {\n    ValidationUtils.rejectIfEmptyOrWhitespace(errors, \"name\", \"name.required\", \"Name is required\");\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n}<\/pre>\n\n\n\n<p>Spring Framework Validation\u306e\u5229\u70b9\u306f\u3001\u5ba3\u8a00\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u3068\u67d4\u8edf\u306a\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u6027\u306b\u3042\u308a\u307e\u3059\u3002\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u306b\u76f4\u63a5\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u5b9a\u7fa9\u3067\u304d\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306b\u7279\u5316\u3057\u305f\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3082\u5b9f\u73fe\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306b\u3001Spring Validation\u306e\u4e3b\u306a\u5229\u70b9\u3092\u307e\u3068\u3081\u307e\u3059\uff1a<\/p>\n\n\n\n<div class=\"wp-block-sgb-message\"><div class=\"memo sng-shadow-0\" style=\"border-radius:0px;background-color:#b4e0fa;color:#009EF3\"><div class=\"memo_ttl dfont\"><span class=\"sng-box-msg__icon\" style=\"background:#009EF3\"><i class=\"far fa-lightbulb\"><\/i><\/span><div class=\"sng-box-msg__title\">\u5229\u70b9<\/div><\/div><div class=\"sng-box-msg__contents\">\n<ol class=\"wp-block-list\">\n<li><strong>\u5ba3\u8a00\u7684\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u7c21\u6f54\u306b\u30eb\u30fc\u30eb\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u62e1\u5f35\u6027<\/strong>: \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u3084\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u72ec\u81ea\u306e\u30eb\u30fc\u30eb\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u7d71\u5408\u6027<\/strong>: Spring MVC\u3084Spring Boot\u3068 seamless\u306b\u7d71\u5408\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u56fd\u969b\u5316\u5bfe\u5fdc<\/strong>: \u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u591a\u8a00\u8a9e\u5316\u304c\u5bb9\u6613\u3067\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c6\u30b9\u30c8\u5bb9\u6613\u6027<\/strong>: \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u5358\u72ec\u3067\u30c6\u30b9\u30c8\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n\n\n\n<p>\u4e00\u65b9\u3067\u3001Spring Validation\u306e\u9650\u754c\u3084\u6ce8\u610f\u70b9\u3082\u7406\u89e3\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<div class=\"wp-block-sgb-message\"><div class=\"memo sng-shadow-0\" style=\"border-radius:0px;background-color:#ffebeb;color:#f88080\"><div class=\"memo_ttl dfont\"><span class=\"sng-box-msg__icon\" style=\"background:#f88080\"><i class=\"fas fa-exclamation\"><\/i><\/span><div class=\"sng-box-msg__title\">\u6ce8\u610f<\/div><\/div><div class=\"sng-box-msg__contents\">\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/strong>: \u5927\u91cf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\u5834\u5408\u3001\u51e6\u7406\u6642\u9593\u306b\u5f71\u97ff\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u8907\u96d1\u6027<\/strong>: \u9ad8\u5ea6\u306a\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u5b9f\u88c5\u304c\u8907\u96d1\u306b\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30d0\u30fc\u30b8\u30e7\u30f3\u4f9d\u5b58<\/strong>: Spring Framework\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u3001\u4e00\u90e8\u306e\u6a5f\u80fd\u3084\u52d5\u4f5c\u304c\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n\n\n\n<p>Spring Framework Validation\u306f\u3001\u3053\u308c\u3089\u306e\u7279\u5fb4\u3092\u7406\u89e3\u3057\u305f\u4e0a\u3067\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5805\u7262\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u3092\u652f\u63f4\u3057\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5\u3068\u5fdc\u7528\u30c6\u30af\u30cb\u30c3\u30af\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">2. Spring Validation\u306e\u57fa\u672c\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/h2>\n\n\n\n<p>Spring Framework\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u306b\u306f\u3001\u4e3b\u306b\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u65b9\u6cd5\u3068\u30d7\u30ed\u30b0\u30e9\u30e0\u7684\u306a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u4e21\u65b9\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u3001\u5b9f\u8df5\u7684\u306a\u30b3\u30fc\u30c9\u4f8b\u3092\u4ea4\u3048\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">2.1 \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a<\/h3>\n\n\n\n<p>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u3092\u9ad8\u3081\u308b\u52b9\u679c\u7684\u306a\u65b9\u6cd5\u3067\u3059\u3002Spring Framework\u306fJava Bean Validation\uff08JSR 380\uff09\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304a\u308a\u3001javax.validation\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u6a19\u6e96\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306b\u4e3b\u8981\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u305d\u306e\u4f7f\u7528\u4f8b\u3092\u793a\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=\"\">import javax.validation.constraints.*;\n\npublic class User {\n    @NotNull(message = \"Name cannot be null\")\n    @Size(min = 2, max = 30, message = \"Name must be between 2 and 30 characters\")\n    private String name;\n\n    @Email(message = \"Email should be valid\")\n    private String email;\n\n    @Min(value = 18, message = \"Age should not be less than 18\")\n    @Max(value = 150, message = \"Age should not be greater than 150\")\n    private int age;\n\n    @Pattern(regexp = \"^[0-9]{10}$\", message = \"Phone number must be 10 digits\")\n    private String phoneNumber;\n\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u30ec\u30d9\u30eb\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u7c21\u6f54\u306b\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>Spring Framework\u306f\u3001\u72ec\u81ea\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3082\u63d0\u4f9b\u3057\u3066\u3044\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=\"\">import org.springframework.format.annotation.DateTimeFormat;\n\npublic class Event {\n    @DateTimeFormat(pattern = \"yyyy-MM-dd\")\n    @Future(message = \"Event date must be in the future\")\n    private Date eventDate;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068getter\/setter\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">2.2 \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u4f5c\u6210\u624b\u9806<\/h3>\n\n\n\n<p>\u7279\u5b9a\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306b\u57fa\u3065\u3044\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u624b\u9806\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9:<\/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=\"\">import javax.validation.Constraint;\nimport javax.validation.Payload;\nimport java.lang.annotation.*;\n\n@Documented\n@Constraint(validatedBy = PasswordStrengthValidator.class)\n@Target({ElementType.FIELD})\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface StrongPassword {\n    String message() default \"Password must be strong\";\n    Class&lt;?&gt;[] groups() default {};\n    Class&lt;? extends Payload&gt;[] payload() default {};\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>ConstraintValidator\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5b9f\u88c5:<\/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=\"\">import javax.validation.ConstraintValidator;\nimport javax.validation.ConstraintValidatorContext;\n\npublic class PasswordStrengthValidator implements ConstraintValidator&lt;StrongPassword, String&gt; {\n\n    @Override\n    public void initialize(StrongPassword constraintAnnotation) {\n    }\n\n    @Override\n    public boolean isValid(String password, ConstraintValidatorContext context) {\n        return password != null &amp;&amp; password.length() &gt;= 8 &amp;&amp;\n               password.matches(\".*[A-Z].*\") &amp;&amp; password.matches(\".*[a-z].*\") &amp;&amp;\n               password.matches(\".*[0-9].*\") &amp;&amp; password.matches(\".*[!@#$%^&amp;*].*\");\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u4f7f\u7528:<\/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 class User {\n    @StrongPassword(message = \"Password must contain at least 8 characters, including uppercase, lowercase, number, and special character\")\n    private String password;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068getter\/setter\n}<\/pre>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u306e\u51e6\u7406\u306f\u3001\u901a\u5e38<code>BindingResult<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u7528\u3057\u3066\u884c\u3044\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=\"\">@PostMapping(\"\/user\")\npublic String createUser(@Valid @ModelAttribute User user, BindingResult result, Model model) {\n    if (result.hasErrors()) {\n        return \"userForm\";\n    }\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u51e6\u7406\n    return \"redirect:\/success\";\n}<\/pre>\n\n\n\n<p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u306f\u3001<code>messages.properties<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3057\u3066\u884c\u3046\u3053\u3068\u304c\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=\"\">NotNull.user.name=Name is required\nSize.user.name=Name must be between {2} and {1} characters\nEmail.user.email=Please provide a valid email address\nStrongPassword.user.password=Password must be strong (8+ chars, upper, lower, digit, special)<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001Spring Framework\u3092\u4f7f\u7528\u3057\u305f\u52b9\u679c\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u308a\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-6\">3. Spring Validation\u306e\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5<\/h2>\n\n\n\n<p>Spring Framework\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u306f\u3001\u57fa\u672c\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u3060\u3051\u3067\u306a\u304f\u3001\u3088\u308a\u8907\u96d1\u306a\u30b7\u30ca\u30ea\u30aa\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u9ad8\u5ea6\u306a\u6280\u6cd5\u3082\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30b0\u30eb\u30fc\u30d7\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3068\u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4e2d\u5fc3\u306b\u3001Spring Validation\u306e\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">3.1 \u30b0\u30eb\u30fc\u30d7\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u6d3b\u7528\u30b7\u30ca\u30ea\u30aa\u3068\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30b0\u30eb\u30fc\u30d7\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u540c\u3058\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u306b\u5bfe\u3057\u3066\u7570\u306a\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u9069\u7528\u3057\u305f\u3044\u5834\u5408\u306b\u975e\u5e38\u306b\u6709\u7528\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u3068\u66f4\u65b0\u6642\u3067\u7570\u306a\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u9069\u7528\u3059\u308b\u5834\u5408\u306a\u3069\u304c\u8a72\u5f53\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30b0\u30eb\u30fc\u30d7\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u624b\u9806\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30b0\u30eb\u30fc\u30d7\u306e\u5b9a\u7fa9:<\/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 interface CreateUser {}\npublic interface UpdateUser {}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u30af\u30e9\u30b9\u3067\u30b0\u30eb\u30fc\u30d7\u3092\u6307\u5b9a:<\/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 class User {\n    @NotNull(groups = {CreateUser.class, UpdateUser.class})\n    @Size(min = 2, max = 30, groups = {CreateUser.class, UpdateUser.class})\n    private String name;\n\n    @NotNull(groups = CreateUser.class)\n    @Email(groups = {CreateUser.class, UpdateUser.class})\n    private String email;\n\n    @NotNull(groups = CreateUser.class)\n    @Size(min = 8, groups = CreateUser.class)\n    private String password;\n\n\n\/\/ getters and setters\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u30b0\u30eb\u30fc\u30d7\u3092\u6307\u5b9a\u3057\u3066\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c:<\/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=\"\">@PostMapping(\"\/user\/create\")\npublic String createUser(@Validated(CreateUser.class) @ModelAttribute User user, BindingResult result) {\n    if (result.hasErrors()) {\n        return \"userForm\";\n    }\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u4f5c\u6210\u30ed\u30b8\u30c3\u30af\n    return \"redirect:\/success\";\n}\n\n@PostMapping(\"\/user\/update\")\npublic String updateUser(@Validated(UpdateUser.class) @ModelAttribute User user, BindingResult result) {\n    if (result.hasErrors()) {\n        return \"userForm\";\n    }\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u66f4\u65b0\u30ed\u30b8\u30c3\u30af\n    return \"redirect:\/success\";\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u65b9\u6cd5\u306b\u3088\u308a\u3001\u540c\u3058User\u30af\u30e9\u30b9\u306b\u5bfe\u3057\u3066\u3001\u4f5c\u6210\u6642\u3068\u66f4\u65b0\u6642\u3067\u7570\u306a\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u9069\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">3.2 \u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u73fe\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u8907\u6570\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u9593\u306e\u95a2\u4fc2\u6027\u3092\u691c\u8a3c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3068\u78ba\u8a8d\u7528\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4e00\u81f4\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u5834\u5408\u306a\u3069\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u73fe\u3059\u308b\u4e3b\u306a\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e2\u3064\u3067\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u30d0\u30ea\u30c7\u30fc\u30bf\u306e\u4f5c\u6210<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u30ec\u30d9\u30eb\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/li>\n<\/ol>\n\n\n\n<p>\u4ee5\u4e0b\u306b\u3001\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u305f\u30af\u30ed\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9:<\/li>\n<\/ol>\n\n\n\n<p><\/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=\"\">@Target({ElementType.TYPE})\n@Retention(RetentionPolicy.RUNTIME)\n@Constraint(validatedBy = PasswordMatchValidator.class)\npublic @interface PasswordMatch {\n    String message() default \"Passwords do not match\";\n    Class&lt;?&gt;[] groups() default {};\n    Class&lt;? extends Payload&gt;[] payload() default {};\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30d0\u30ea\u30c7\u30fc\u30bf\u306e\u5b9f\u88c5:<\/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 class PasswordMatchValidator implements ConstraintValidator&lt;PasswordMatch, Object&gt; {\n\n    @Override\n    public void initialize(PasswordMatch constraintAnnotation) {\n    }\n\n    @Override\n    public boolean isValid(Object obj, ConstraintValidatorContext context) {\n        User user = (User) obj;\n        return user.getPassword().equals(user.getConfirmPassword());\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u9069\u7528:<\/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=\"\">@PasswordMatch(message = \"Password and Confirm Password must match\")\npublic class User {\n    private String password;\n    private String confirmPassword;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3001getters\u3001setters\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u65b9\u6cd5\u306b\u3088\u308a\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3068\u78ba\u8a8d\u7528\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4e00\u81f4\u3057\u3066\u3044\u308b\u304b\u3092\u691c\u8a3c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3055\u3089\u306b\u3001Spring Validation\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u9ad8\u5ea6\u306a\u6280\u6cd5\u3082\u6d3b\u7528\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8907\u5408\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u8907\u6570\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u3088\u308a\u8907\u96d1\u306a\u6761\u4ef6\u3092\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\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=\"\">@Pattern(regexp = \"^[A-Z].*\", message = \"Must start with an uppercase letter\")\n@Size(min = 8, max = 30, message = \"Must be between 8 and 30 characters\")\nprivate String username;<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6761\u4ef6\u4ed8\u304d\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u7279\u5b9a\u306e\u6761\u4ef6\u4e0b\u3067\u306e\u307f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u9069\u7528\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002 <\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30ab\u30fc\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u30cd\u30b9\u30c8\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u9069\u7528\u3059\u308b\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<code>@Valid<\/code>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\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 class Order {\n    @Valid\n    private Customer customer;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\n}<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52d5\u7684\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u5b9f\u884c\u6642\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u3001<code>Validator<\/code>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u305f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u7684\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u9ad8\u5ea6\u306a\u4f7f\u7528\u6280\u6cd5\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u3084\u8981\u4ef6\u306b\u5bfe\u5fdc\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u904e\u5ea6\u306b\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306f\u4fdd\u5b88\u6027\u3092\u4f4e\u4e0b\u3055\u305b\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u9069\u5207\u306a\u30d0\u30e9\u30f3\u30b9\u3092\u4fdd\u3064\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001RESTful API\u306b\u304a\u3051\u308bSpring Validation\u306e\u6700\u9069\u306a\u5229\u7528\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">4. RESTful API\u306b\u304a\u3051\u308bSpring Validation\u306e\u6700\u9069\u306a\u5229\u7528\u6cd5<\/h2>\n\n\n\n<p>RESTful API\u306e\u8a2d\u8a08\u3068\u5b9f\u88c5\u306b\u304a\u3044\u3066\u3001\u9069\u5207\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u975e\u5e38\u306b\u91cd\u8981\u3067\u3059\u3002\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u53d7\u3051\u53d6\u308b\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u78ba\u4fdd\u3057\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30ea\u30b9\u30af\u3092\u8efd\u6e1b\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001API\u306e\u5805\u7262\u6027\u3068\u4fe1\u983c\u6027\u3092\u9ad8\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Framework\u3092\u4f7f\u7528\u3057\u305fRESTful API\u306b\u304a\u3051\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u6700\u9069\u306a\u5b9f\u88c5\u65b9\u6cd5\u3068\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">4.1 \u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>RESTful API\u3067\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u7279\u306b\u91cd\u8981\u3067\u3059\u3002Spring Framework\u3067\u306f\u3001<code>@Valid<\/code>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u7c21\u5358\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>DTO\u30af\u30e9\u30b9\u306e\u5b9a\u7fa9:<\/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 class UserDTO {\n    @NotNull(message = \"Name cannot be null\")\n    @Size(min = 2, max = 30, message = \"Name must be between 2 and 30 characters\")\n    private String name;\n\n    @Email(message = \"Email should be valid\")\n    private String email;\n\n    @Min(value = 18, message = \"Age should not be less than 18\")\n    private int age;\n\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3:<\/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=\"\">@RestController\n@RequestMapping(\"\/api\/users\")\npublic class UserController {\n\n    @PostMapping\n    public ResponseEntity&lt;UserDTO&gt; createUser(@Valid @RequestBody UserDTO userDTO) {\n        \/\/ \u30e6\u30fc\u30b6\u30fc\u4f5c\u6210\u30ed\u30b8\u30c3\u30af\n        return ResponseEntity.ok(userDTO);\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u65b9\u6cd5\u306b\u3088\u308a\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u304c\u81ea\u52d5\u7684\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u3001\u7121\u52b9\u306a\u30c7\u30fc\u30bf\u304c\u691c\u51fa\u3055\u308c\u305f\u5834\u5408\u306f<code>MethodArgumentNotValidException<\/code>\u304c\u30b9\u30ed\u30fc\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">4.2 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u3092\u9069\u5207\u306b\u51e6\u7406\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u6709\u7528\u306a\u60c5\u5831\u3092\u8fd4\u3059\u3053\u3068\u306f\u3001\u826f\u3044API\u8a2d\u8a08\u306e\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\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=\"\">@ControllerAdvice\npublic class GlobalExceptionHandler extends ResponseEntityExceptionHandler {\n\n    @Override\n    protected ResponseEntity&lt;Object&gt; handleMethodArgumentNotValid(MethodArgumentNotValidException ex,\n            HttpHeaders headers, HttpStatus status, WebRequest request) {\n        Map&lt;String, String&gt; errors = new HashMap&lt;&gt;();\n        ex.getBindingResult().getAllErrors().forEach((error) -&gt; {\n            String fieldName = ((FieldError) error).getField();\n            String errorMessage = error.getDefaultMessage();\n            errors.put(fieldName, errorMessage);\n        });\n        return new ResponseEntity&lt;&gt;(errors, HttpStatus.BAD_REQUEST);\n    }\n\n    @ExceptionHandler(ConstraintViolationException.class)\n    public ResponseEntity&lt;Object&gt; handleConstraintViolationException(ConstraintViolationException ex) {\n        Map&lt;String, String&gt; errors = new HashMap&lt;&gt;();\n        ex.getConstraintViolations().forEach(violation -&gt; {\n            String fieldName = violation.getPropertyPath().toString();\n            String errorMessage = violation.getMessage();\n            errors.put(fieldName, errorMessage);\n        });\n        return new ResponseEntity&lt;&gt;(errors, HttpStatus.BAD_REQUEST);\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u8a73\u7d30\u306a\u30a8\u30e9\u30fc\u60c5\u5831\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30d1\u30b9\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u30d1\u30b9\u30d1\u30e9\u30e1\u30fc\u30bf\u3084\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3082\u91cd\u8981\u3067\u3059\u3002\u3053\u308c\u3089\u306f<code>@PathVariable<\/code>\u3068<code>@RequestParam<\/code>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u88c5\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=\"\">@GetMapping(\"\/users\/{id}\")\npublic ResponseEntity&lt;UserDTO&gt; getUser(\n        @PathVariable @Min(1) Long id,\n        @RequestParam @Email String email) {\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u53d6\u5f97\u30ed\u30b8\u30c3\u30af\n    return ResponseEntity.ok(new UserDTO());\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u5834\u5408\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u306f<code>ConstraintViolationException<\/code>\u3068\u3057\u3066\u30b9\u30ed\u30fc\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u9762\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u5358\u306a\u308b\u30c7\u30fc\u30bf\u6574\u5408\u6027\u306e\u78ba\u4fdd\u3060\u3051\u3067\u306a\u304f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\u3068\u3057\u3066\u3082\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u70b9\u306b\u7279\u306b\u6ce8\u610f\u3092\u6255\u3046\u3079\u304d\u3067\u3059\uff1a<\/p>\n\n\n\n<div class=\"wp-block-sgb-message\"><div class=\"memo sng-shadow-0\" style=\"border-radius:0px;background-color:#ffebeb;color:#f88080\"><div class=\"memo_ttl dfont\"><span class=\"sng-box-msg__icon\" style=\"background:#f88080\"><i class=\"fas fa-exclamation\"><\/i><\/span><div class=\"sng-box-msg__title\">\u6ce8\u610f<\/div><\/div><div class=\"sng-box-msg__contents\">\n<ol class=\"wp-block-list\">\n<li>\u5165\u529b\u30c7\u30fc\u30bf\u306e\u30b5\u30cb\u30bf\u30a4\u30ba: XSS\u306a\u3069\u306e\u653b\u6483\u3092\u9632\u3050\u305f\u3081\u3001\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306f\u5e38\u306b\u30a8\u30b9\u30b1\u30fc\u30d7\u307e\u305f\u306f\u30b5\u30cb\u30bf\u30a4\u30ba\u3059\u308b\u3002<\/li>\n\n\n\n<li>\u30b5\u30a4\u30ba\u5236\u9650: \u5927\u91cf\u306e\u30c7\u30fc\u30bf\u9001\u4fe1\u306b\u3088\u308b\u653b\u6483\u3092\u9632\u3050\u305f\u3081\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30b5\u30a4\u30ba\u306b\u5236\u9650\u3092\u8a2d\u3051\u308b\u3002<\/li>\n\n\n\n<li>\u30ec\u30fc\u30c8\u5236\u9650: API\u306e\u904e\u5270\u306a\u4f7f\u7528\u3092\u9632\u3050\u305f\u3081\u3001\u30ec\u30fc\u30c8\u5236\u9650\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8003\u616e\u4e8b\u9805<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306fAPI\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u70b9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\uff1a<\/p>\n\n\n\n<div class=\"wp-block-sgb-message\"><div class=\"memo sng-shadow-0\" style=\"border-radius:0px;background-color:#ffebeb;color:#f88080\"><div class=\"memo_ttl dfont\"><span class=\"sng-box-msg__icon\" style=\"background:#f88080\"><i class=\"fas fa-exclamation\"><\/i><\/span><div class=\"sng-box-msg__title\">\u6ce8\u610f<\/div><\/div><div class=\"sng-box-msg__contents\">\n<ol class=\"wp-block-list\">\n<li>\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3: \u904e\u5270\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u907f\u3051\u3001\u5fc5\u8981\u306a\u30c1\u30a7\u30c3\u30af\u306e\u307f\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6d3b\u7528: \u983b\u7e41\u306b\u4f7f\u7528\u3055\u308c\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3002<\/li>\n\n\n\n<li>\u975e\u540c\u671f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3: \u91cd\u3044\u51e6\u7406\u304c\u5fc5\u8981\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u975e\u540c\u671f\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3092\u691c\u8a0e\u3059\u308b\u3002<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n\n\n\n<p>RESTful API\u306b\u304a\u3051\u308bSpring Validation\u306e\u9069\u5207\u306a\u5b9f\u88c5\u306f\u3001API\u306e\u54c1\u8cea\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3001\u304a\u3088\u3073\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u306e\u5411\u4e0a\u306b\u5927\u304d\u304f\u5bc4\u4e0e\u3057\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">5. Spring Validation\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/h2>\n\n\n\n<p>Spring Validation\u306f\u5f37\u529b\u306a\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u304c\u3001\u9069\u5207\u306b\u4f7f\u7528\u3057\u306a\u3044\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u306e\u69d8\u3005\u306a\u6280\u6cd5\u3068\u6226\u7565\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">5.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u306e\u52b9\u7387\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u65e9\u671f\u30ea\u30bf\u30fc\u30f3<\/strong>: \u6700\u3082\u4e00\u822c\u7684\u306a\u30a8\u30e9\u30fc\u3092\u5148\u306b\u691c\u8a3c\u3057\u3001\u7121\u52b9\u306a\u5165\u529b\u3092\u65e9\u671f\u306b\u62d2\u5426\u3059\u308b\u3053\u3068\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u307e\u3059\u3002<\/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 boolean isValid(String input, ConstraintValidatorContext context) {\n    if (input == null || input.isEmpty()) {\n        return false;\n    }\n    \/\/ \u305d\u306e\u4ed6\u306e\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u8efd\u91cf\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u512a\u5148<\/strong>: \u8a08\u7b97\u30b3\u30b9\u30c8\u306e\u4f4e\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5148\u306b\u5b9f\u884c\u3057\u3001\u91cd\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u5fc5\u8981\u306a\u5834\u5408\u306e\u307f\u884c\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u306e\u6700\u9069\u5316<\/strong>: \u8907\u96d1\u306a\u30ed\u30b8\u30c3\u30af\u3092\u542b\u3080\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u306f\u3001\u52b9\u7387\u7684\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/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 class OptimizedEmailValidator implements ConstraintValidator&lt;ValidEmail, String&gt; {\n    private static final Pattern EMAIL_PATTERN = Pattern.compile(\"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\\\.[A-Z]{2,6}$\", Pattern.CASE_INSENSITIVE);\n\n    @Override\n    public boolean isValid(String email, ConstraintValidatorContext context) {\n        return email != null &amp;&amp; EMAIL_PATTERN.matcher(email).matches();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">5.2 \u5927\u898f\u6a21\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u5404\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u3067\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3044\u3001\u91cd\u8907\u3092\u907f\u3051\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u5206\u6563\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u5927\u91cf\u306e\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u5834\u5408\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5206\u6563\u3057\u3066\u4e26\u5217\u51e6\u7406\u3059\u308b\u3053\u3068\u3067\u5168\u4f53\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/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=\"\">@Service\npublic class DistributedValidationService {\n    @Autowired\n    private ExecutorService executorService;\n\n    public List&lt;ValidationResult&gt; validateBulk(List&lt;Data&gt; dataList) {\n        return dataList.parallelStream()\n                       .map(this::validateAsync)\n                       .map(CompletableFuture::join)\n                       .collect(Collectors.toList());\n    }\n\n    private CompletableFuture&lt;ValidationResult&gt; validateAsync(Data data) {\n        return CompletableFuture.supplyAsync(() -&gt; validate(data), executorService);\n    }\n\n    private ValidationResult validate(Data data) {\n        \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u672c\u5f53\u306b\u5fc5\u8981\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u307f\u3092\u5b9f\u88c5\u3057\u3001\u904e\u5270\u306a\u30c1\u30a7\u30c3\u30af\u306f\u907f\u3051\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30b0\u30eb\u30fc\u30d7\u5316<\/strong>: <code>@GroupSequence<\/code>\u3092\u4f7f\u7528\u3057\u3066\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u9806\u5e8f\u3092\u5236\u5fa1\u3057\u3001\u4e0d\u5fc5\u8981\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u56de\u907f\u3057\u307e\u3059\u3002<\/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=\"\">@GroupSequence({FirstCheck.class, SecondCheck.class, User.class})\npublic class User {\n    @NotNull(groups = FirstCheck.class)\n    @Size(min = 2, max = 30, groups = SecondCheck.class)\n    private String name;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6d3b\u7528<\/strong>: \u983b\u7e41\u306b\u4f7f\u7528\u3055\u308c\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u3067\u3001\u518d\u8a08\u7b97\u3092\u907f\u3051\u307e\u3059\u3002<\/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=\"\">@Service\npublic class CachedValidationService {\n    @Autowired\n    private Cache validationCache;\n\n    public boolean isValid(String input) {\n        return validationCache.get(input, key -&gt; {\n            \/\/ \u5b9f\u969b\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n            return performExpensiveValidation(key);\n        });\n    }\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u975e\u540c\u671f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u91cd\u3044\u51e6\u7406\u3092\u542b\u3080\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u975e\u540c\u671f\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3092\u691c\u8a0e\u3057\u307e\u3059\u3002<\/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=\"\">@Service\npublic class AsyncValidationService {\n    @Async\n    public CompletableFuture&lt;Boolean&gt; validateAsync(ComplexData data) {\n        return CompletableFuture.supplyAsync(() -&gt; {\n            \/\/ \u6642\u9593\u306e\u304b\u304b\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n            return performComplexValidation(data);\n        });\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u6280\u8853\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001Spring Validation\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u6700\u9069\u5316\u3092\u884c\u3046\u524d\u306b\u3001\u5fc5\u305a\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u3068\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u30c6\u30b9\u30c8\u3092\u5b9f\u65bd\u3057\u3001\u5b9f\u969b\u306e\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u904e\u5ea6\u306e\u6700\u9069\u5316\u306f\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u3092\u640d\u306a\u3046\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u30d0\u30e9\u30f3\u30b9\u3092\u53d6\u308a\u306a\u304c\u3089\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u6c42\u3081\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u3068TDD\uff08\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff09\u306e\u7d71\u5408\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-19\">6. Spring Validation\u3068\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09<\/h2>\n\n\n\n<p>\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u306f\u3001\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u3092\u5411\u4e0a\u3055\u305b\u3001\u30d0\u30b0\u3092\u65e9\u671f\u306b\u767a\u898b\u3059\u308b\u305f\u3081\u306e\u52b9\u679c\u7684\u306a\u624b\u6cd5\u3067\u3059\u3002Spring Validation\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u958b\u767a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001TDD\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u7528\u3044\u305fSpring Validation\u306e\u5b9f\u88c5\u65b9\u6cd5\u3068\u3001\u52b9\u679c\u7684\u306a\u30c6\u30b9\u30c8\u6226\u7565\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">6.1 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u624b\u6cd5<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u306f\u3001\u500b\u3005\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u304c\u671f\u5f85\u901a\u308a\u306b\u6a5f\u80fd\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001JUnit\u3068AssertJ\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\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=\"\">import org.junit.jupiter.api.Test;\nimport static org.assertj.core.api.Assertions.*;\n\nclass UserValidationTest {\n\n    @Test\n    void testEmailValidation() {\n        User user = new User();\n        user.setEmail(\"invalid-email\");\n\n        Set&lt;ConstraintViolation&lt;User&gt;&gt; violations = validator.validate(user);\n\n        assertThat(violations).isNotEmpty();\n        assertThat(violations).extracting(\"message\").contains(\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u5f62\u5f0f\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\");\n    }\n\n    @Test\n    void testNameLength() {\n        User user = new User();\n        user.setName(\"A\");\n\n        Set&lt;ConstraintViolation&lt;User&gt;&gt; violations = validator.validate(user);\n\n        assertThat(violations).isNotEmpty();\n        assertThat(violations).extracting(\"message\").contains(\"\u540d\u524d\u306f2\u6587\u5b57\u4ee5\u4e0a30\u6587\u5b57\u4ee5\u4e0b\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\");\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">6.2 \u30e2\u30c3\u30af\u3092\u6d3b\u7528\u3057\u305f\u7d71\u5408\u30c6\u30b9\u30c8\u306e\u5b9f\u88c5\u4f8b<\/h3>\n\n\n\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30ec\u30d9\u30eb\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u306b\u306f\u3001Spring Test\u3068Mockito\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001<code>@WebMvcTest<\/code>\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30b9\u30c8\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=\"\">@WebMvcTest(UserController.class)\nclass UserControllerTest {\n\n    @Autowired\n    private MockMvc mockMvc;\n\n    @Test\n    void testCreateUserValidation() throws Exception {\n        mockMvc.perform(post(\"\/api\/users\")\n                .contentType(MediaType.APPLICATION_JSON)\n                .content(\"{\\\"name\\\":\\\"\\\",\\\"email\\\":\\\"invalid-email\\\"}\"))\n                .andExpect(status().isBadRequest())\n                .andExpect(jsonPath(\"$.name\").value(\"\u540d\u524d\u306f\u5fc5\u9808\u3067\u3059\"))\n                .andExpect(jsonPath(\"$.email\").value(\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u5f62\u5f0f\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\"));\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">TDD\u3092\u7528\u3044\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u958b\u767a\u30d7\u30ed\u30bb\u30b9<\/h3>\n\n\n\n<p>TDD\u306e\u57fa\u672c\u30b5\u30a4\u30af\u30eb\u3067\u3042\u308b\u300cRed-Green-Refactor\u300d\u3092\u7528\u3044\u3066\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u958b\u767a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Red<\/strong>: \u307e\u305a\u3001\u5931\u6557\u3059\u308b\u30c6\u30b9\u30c8\u3092\u66f8\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>Green<\/strong>: \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u5b9f\u88c5\u3057\u3001\u30c6\u30b9\u30c8\u304c\u901a\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>Refactor<\/strong>: \u30b3\u30fc\u30c9\u3092\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3057\u3001\u54c1\u8cea\u3092\u5411\u4e0a\u3055\u305b\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5e74\u9f62\u306b\u5bfe\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u958b\u767a\u3059\u308b\u5834\u5408\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=\"\">@Test\nvoid testAgeValidation() {\n    User user = new User();\n    user.setAge(-1);\n\n    Set&lt;ConstraintViolation&lt;User&gt;&gt; violations = validator.validate(user);\n\n    assertThat(violations).isNotEmpty();\n    assertThat(violations).extracting(\"message\").contains(\"\u5e74\u9f62\u306f0\u4ee5\u4e0a\u306e\u6574\u6570\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\");\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u30c6\u30b9\u30c8\u3092\u901a\u3059\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u5b9f\u88c5\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=\"\">public class User {\n    @Min(value = 0, message = \"\u5e74\u9f62\u306f0\u4ee5\u4e0a\u306e\u6574\u6570\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\")\n    private int age;\n\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u3068\u5883\u754c\u5024\u30c6\u30b9\u30c8<\/h3>\n\n\n\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u30c6\u30b9\u30c8\u3067\u306f\u3001\u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u3068\u5883\u754c\u5024\u306e\u30c6\u30b9\u30c8\u304c\u7279\u306b\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b1\u30fc\u30b9\u3092\u8003\u616e\u3057\u3066\u30c6\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>null\u5024<\/li>\n\n\n\n<li>\u7a7a\u6587\u5b57\u5217<\/li>\n\n\n\n<li>\u6700\u5c0f\u5024\u3001\u6700\u5927\u5024<\/li>\n\n\n\n<li>\u5883\u754c\u5024\uff08\u4f8b\uff1a\u6700\u5c0f\u5024-1\u3001\u6700\u5927\u5024+1\uff09<\/li>\n\n\n\n<li>\u7279\u6b8a\u6587\u5b57\u3084\u4e0d\u6b63\u306a\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf<\/li>\n<\/ul>\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=\"\">@Test\nvoid testNameLengthBoundary() {\n    User user = new User();\n\n    user.setName(\"A\"); \/\/ \u6700\u5c0f\u9577 - 1\n    assertThat(validator.validate(user)).isNotEmpty();\n\n    user.setName(\"AB\"); \/\/ \u6700\u5c0f\u9577\n    assertThat(validator.validate(user)).isEmpty();\n\n    user.setName(\"A\".repeat(30)); \/\/ \u6700\u5927\u9577\n    assertThat(validator.validate(user)).isEmpty();\n\n    user.setName(\"A\".repeat(31)); \/\/ \u6700\u5927\u9577 + 1\n    assertThat(validator.validate(user)).isNotEmpty();\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027<\/h3>\n\n\n\n<p>\u9ad8\u54c1\u8cea\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u7dad\u6301\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u9ad8\u3044\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u3068\u30c6\u30b9\u30c8\u306e\u4fdd\u5b88\u6027\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u6e2c\u5b9a<\/strong>: JaCoCo\u306a\u3069\u306e\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u3092\u5b9a\u671f\u7684\u306b\u6e2c\u5b9a\u3057\u3001\u4e0d\u8db3\u3057\u3066\u3044\u308b\u90e8\u5206\u3092\u7279\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u547d\u540d<\/strong>: \u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306e\u540d\u524d\u306f\u3001\u30c6\u30b9\u30c8\u306e\u76ee\u7684\u3084\u6761\u4ef6\u3092\u660e\u78ba\u306b\u8868\u73fe\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/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=\"\">@Test\nvoid shouldRejectEmailWithoutAtSymbol() {\n    \/\/ \u30c6\u30b9\u30c8\u5b9f\u88c5\n}\n\n@Test\nvoid shouldAcceptValidEmailFormat() {\n    \/\/ \u30c6\u30b9\u30c8\u5b9f\u88c5\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3<\/strong>: \u8907\u96d1\u306a\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306b\u306f\u3001<code>@DisplayName<\/code>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3084\u30b3\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u8aac\u660e\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/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=\"\">@Test\n@DisplayName(\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u691c\u8a3c: \u7279\u6b8a\u6587\u5b57\u3092\u542b\u3080\u6709\u52b9\u306a\u30b1\u30fc\u30b9\")\nvoid testEmailValidationWithSpecialCharacters() {\n    \/\/ \u30c6\u30b9\u30c8\u5b9f\u88c5\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u96c6\u4e2d\u7ba1\u7406<\/strong>: \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u5185\u306e\u5b9a\u6570\u3084\u5c02\u7528\u306e\u30d5\u30a1\u30af\u30c8\u30ea\u30fc\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3001\u518d\u5229\u7528\u6027\u3092\u9ad8\u3081\u307e\u3059\u3002<\/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=\"\">class UserTestDataFactory {\n    static User createValidUser() {\n        User user = new User();\n        user.setName(\"John Doe\");\n        user.setEmail(\"john@example.com\");\n        user.setAge(30);\n        return user;\n    }\n\n    static User createUserWithInvalidEmail() {\n        User user = createValidUser();\n        user.setEmail(\"invalid-email\");\n        return user;\n    }\n}<\/pre>\n\n\n\n<p>TDD\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u7528\u3044\u305fSpring Validation\u306e\u958b\u767a\u306f\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u54c1\u8cea\u3068\u4fe1\u983c\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u307e\u3059\u3002\u7dbf\u5bc6\u306b\u30c6\u30b9\u30c8\u3055\u308c\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5168\u4f53\u306e\u5805\u7262\u6027\u3092\u9ad8\u3081\u3001\u30d0\u30b0\u306e\u65e9\u671f\u767a\u898b\u3068\u4fee\u6b63\u306b\u8ca2\u732e\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30c6\u30b9\u30c8\u304c\u5145\u5b9f\u3057\u3066\u3044\u308b\u3053\u3068\u3067\u3001\u5c06\u6765\u306e\u6a5f\u80fd\u8ffd\u52a0\u3084\u5909\u66f4\u3082\u5b89\u5168\u306b\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u306e\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u308c\u307e\u3067\u306b\u5b66\u3093\u3060\u6982\u5ff5\u3068\u6280\u8853\u3092\u3001\u5b9f\u969b\u306e\u30b7\u30ca\u30ea\u30aa\u306b\u3069\u306e\u3088\u3046\u306b\u9069\u7528\u3059\u308b\u304b\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-25\">7. Spring Validation\u306e\u5b9f\u8df5\u7684\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/h2>\n\n\n\n<p>Spring Validation\u306f\u69d8\u3005\u306a\u5b9f\u8df5\u7684\u30b7\u30ca\u30ea\u30aa\u3067\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u4e00\u822c\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u305d\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3001Spring Validation\u306e\u5b9f\u8df5\u7684\u306a\u5fdc\u7528\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">7.1 \u30d5\u30a9\u30fc\u30e0\u9001\u4fe1\u6642\u306e\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/h3>\n\n\n\n<p>Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d5\u30a9\u30fc\u30e0\u30c7\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u91cd\u8981\u3067\u3059\u3002Spring MVC\u3068\u7d71\u5408\u3057\u305f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\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=\"\">@Controller\npublic class UserController {\n\n    @PostMapping(\"\/user\/register\")\n    public String registerUser(@Valid @ModelAttribute(\"user\") UserForm userForm, BindingResult result, Model model) {\n        if (result.hasErrors()) {\n            return \"userRegistrationForm\";\n        }\n        \/\/ \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u51e6\u7406\n        return \"redirect:\/registration-success\";\n    }\n}\n\npublic class UserForm {\n    @NotBlank(message = \"\u540d\u524d\u306f\u5fc5\u9808\u3067\u3059\")\n    @Size(min = 2, max = 50, message = \"\u540d\u524d\u306f2\u301c50\u6587\u5b57\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\")\n    private String name;\n\n    @Email(message = \"\u6709\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\")\n    private String email;\n\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>@Valid<\/code>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3001<code>BindingResult<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u30a8\u30e9\u30fc\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">7.2 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u9023\u643a\u6642\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u306e\u7d44\u307f\u8fbc\u307f\u65b9<\/h3>\n\n\n\n<p>JPA\/Hibernate\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u30af\u30e9\u30b9\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u524d\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\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=\"\">@Entity\npublic class User {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @NotBlank\n    @Column(nullable = false)\n    private String username;\n\n    @Email\n    @Column(unique = true)\n    private String email;\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3001getters\u3001setters\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u8a2d\u5b9a\u306b\u3088\u308a\u3001\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u306e\u6c38\u7d9a\u5316\u3084\u66f4\u65b0\u6642\u306b\u81ea\u52d5\u7684\u306b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-28\">\u8907\u96d1\u306a\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306b\u57fa\u3065\u304f\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u7279\u5b9a\u306e\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306b\u57fa\u3065\u304f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5e74\u9f62\u3068\u5f79\u5272\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30bf\u306e\u4f8b\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=\"\">@Target({ElementType.TYPE})\n@Retention(RetentionPolicy.RUNTIME)\n@Constraint(validatedBy = AgeRoleValidator.class)\npublic @interface ValidAgeRole {\n    String message() default \"Invalid age for the given role\";\n    Class&lt;?&gt;[] groups() default {};\n    Class&lt;? extends Payload&gt;[] payload() default {};\n}\n\npublic class AgeRoleValidator implements ConstraintValidator&lt;ValidAgeRole, User&gt; {\n    @Override\n    public boolean isValid(User user, ConstraintValidatorContext context) {\n        if (user.getRole() == Role.SENIOR &amp;&amp; user.getAge() &lt; 30) {\n            context.disableDefaultConstraintViolation();\n            context.buildConstraintViolationWithTemplate(\"Senior role requires age 30 or above\")\n                   .addPropertyNode(\"age\").addConstraintViolation();\n            return false;\n        }\n        return true;\n    }\n}\n\n@ValidAgeRole\npublic class User {\n    private String name;\n    private int age;\n    private Role role;\n    \/\/ getters and setters\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-29\">\u591a\u8a00\u8a9e\u5bfe\u5fdc\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30e1\u30c3\u30bb\u30fc\u30b8<\/h3>\n\n\n\n<p>\u56fd\u969b\u5316\u5bfe\u5fdc\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30e1\u30c3\u30bb\u30fc\u30b8\u3082\u591a\u8a00\u8a9e\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002Spring \u306e <code>MessageSource<\/code> \u3092\u4f7f\u7528\u3057\u3066\u3001\u3053\u308c\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30c3\u30bb\u30fc\u30b8\u30d7\u30ed\u30d1\u30c6\u30a3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210:<\/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=\"\"># messages_ja.properties\nNotBlank.user.name=\u540d\u524d\u306f\u5fc5\u9808\u3067\u3059\nEmail.user.email=\u6709\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\n\n# messages_en.properties\nNotBlank.user.name=Name is required\nEmail.user.email=Please enter a valid email address<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>MessageSource \u306e\u8a2d\u5b9a:<\/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=\"\">@Configuration\npublic class MessageConfig {\n    @Bean\n    public MessageSource messageSource() {\n        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();\n        messageSource.setBasename(\"classpath:messages\");\n        messageSource.setDefaultEncoding(\"UTF-8\");\n        return messageSource;\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u30ed\u30b1\u30fc\u30eb\u306b\u57fa\u3065\u3044\u3066\u9069\u5207\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-30\">\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\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3082\u3001Spring Validation\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u88c5\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=\"\">public class FileUploadForm {\n    @NotNull\n    @FileSize(max = \"5MB\")\n    @FileType(types = {\"image\/jpeg\", \"image\/png\"})\n    private MultipartFile file;\n\n    \/\/ getter and setter\n}\n\npublic class FileSizeValidator implements ConstraintValidator&lt;FileSize, MultipartFile&gt; {\n    private long maxSizeBytes;\n\n    @Override\n    public void initialize(FileSize constraintAnnotation) {\n        this.maxSizeBytes = parseSize(constraintAnnotation.max());\n    }\n\n    @Override\n    public boolean isValid(MultipartFile file, ConstraintValidatorContext context) {\n        return file == null || file.getSize() &lt;= maxSizeBytes;\n    }\n\n    \/\/ parseSize method implementation\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3092\u901a\u3058\u3066\u3001Spring Validation\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u69d8\u3005\u306a\u5074\u9762\u3067\u6d3b\u7528\u3067\u304d\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002\u9069\u5207\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u3092\u9078\u629e\u3057\u3001\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5805\u7262\u6027\u3068\u4fe1\u983c\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u306e\u6700\u65b0\u30c8\u30ec\u30f3\u30c9\u3068\u4eca\u5f8c\u306e\u5c55\u671b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-31\">8. Spring Validation\u306e\u6700\u65b0\u30c8\u30ec\u30f3\u30c9\u3068\u4eca\u5f8c\u306e\u5c55\u671b<\/h2>\n\n\n\n<p>Spring Validation\u306f\u5e38\u306b\u9032\u5316\u3092\u7d9a\u3051\u3066\u304a\u308a\u3001\u65b0\u3057\u3044\u6280\u8853\u3084\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u5909\u5316\u306b\u9069\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Spring Validation\u306e\u6700\u65b0\u30c8\u30ec\u30f3\u30c9\u3068\u5c06\u6765\u306e\u5c55\u671b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-32\">8.1 Jakarta Bean Validation\u3068\u306e\u7d71\u5408\u52d5\u5411<\/h3>\n\n\n\n<p>Spring Framework\u306fJakarta EE 9\u3078\u306e\u79fb\u884c\u3092\u9032\u3081\u3066\u304a\u308a\u3001\u3053\u308c\u306b\u4f34\u3044Bean Validation\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u304c<code>javax.validation<\/code>\u304b\u3089<code>jakarta.validation<\/code>\u306b\u5909\u66f4\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u79fb\u884c\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5909\u66f4\u304c\u5fc5\u8981\u306b\u306a\u308a\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=\"\">\/\/ Before\nimport javax.validation.constraints.NotNull;\n\n\/\/ After\nimport jakarta.validation.constraints.NotNull;<\/pre>\n\n\n\n<p>\u958b\u767a\u8005\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f9d\u5b58\u95a2\u4fc2\u3068\u30a4\u30f3\u30dd\u30fc\u30c8\u6587\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u5909\u66f4\u306b\u3088\u308aJakarta EE\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u4e92\u63db\u6027\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-33\">8.2 \u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u304a\u3051\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/h3>\n\n\n\n<p>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u666e\u53ca\u306b\u4f34\u3044\u3001\u5206\u6563\u30b7\u30b9\u30c6\u30e0\u306b\u304a\u3051\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u3082\u9032\u5316\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>API Gateway\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: \u5171\u901a\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092API Gateway\u30ec\u30d9\u30eb\u3067\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u30b5\u30fc\u30d3\u30b9\u306e\u8ca0\u8377\u3092\u8efd\u6e1b\u3057\u307e\u3059\u3002<\/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=\"\">@Component\npublic class GlobalValidator extends AbstractMappingValidator {\n    @Override\n    protected void doValidate(Object target, Errors errors) {\n        \/\/ \u5171\u901a\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: gRPC\u3084Protocol Buffers\u3092\u4f7f\u7528\u3057\u3066\u3001\u30b5\u30fc\u30d3\u30b9\u9593\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u5171\u6709\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-34\">\u65b0\u3057\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6280\u8853\u3068\u624b\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5ba3\u8a00\u7684\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u9032\u5316<\/strong>: \u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30dd\u30b8\u30c3\u30c8\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u30e1\u30bf\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u6d3b\u7528\u3057\u3066\u3001\u3088\u308a\u8868\u73fe\u529b\u8c4a\u304b\u3067\u518d\u5229\u7528\u53ef\u80fd\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/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=\"\">@Documented\n@Constraint(validatedBy = {})\n@NotNull\n@Size(min = 5, max = 50)\n@Pattern(regexp = \"^[a-zA-Z0-9]+$\")\n@Target({ElementType.FIELD})\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface ValidUsername {\n    String message() default \"Invalid username\";\n    Class&lt;?&gt;[] groups() default {};\n    Class&lt;? extends Payload&gt;[] payload() default {};\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>: Project Reactor\u3068\u306e\u7d71\u5408\u306b\u3088\u308a\u3001\u975e\u540c\u671f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u6700\u9069\u5316\u304c\u9032\u3093\u3067\u3044\u307e\u3059\u3002<\/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 Mono&lt;ServerResponse&gt; createUser(ServerRequest request) {\n    return request.bodyToMono(User.class)\n        .flatMap(this::validateUser)\n        .flatMap(userService::createUser)\n        .flatMap(user -&gt; ServerResponse.ok().bodyValue(user));\n}\n\nprivate Mono&lt;User&gt; validateUser(User user) {\n    return Mono.fromCallable(() -&gt; {\n        validator.validate(user);\n        return user;\n    }).onErrorResume(ConstraintViolationException.class, \n        e -&gt; Mono.error(new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage())));\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-35\">Spring Framework 6.0\u306e\u65b0\u6a5f\u80fd<\/h3>\n\n\n\n<p>Spring Framework 6.0\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6539\u5584\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>Java 17\u4ee5\u964d\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n\n\n\n<li>AOT\u30b3\u30f3\u30d1\u30a4\u30eb\u306e\u30b5\u30dd\u30fc\u30c8\u5f37\u5316<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6539\u5584\u306b\u3088\u308a\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u306e\u52b9\u7387\u304c\u5411\u4e0a\u3057\u3001\u3088\u308a\u9ad8\u901f\u306a\u5b9f\u884c\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-36\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u7d71\u5408<\/h3>\n\n\n\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3078\u306e\u95a2\u5fc3\u306e\u9ad8\u307e\u308a\u306b\u3088\u308a\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\u306e\u7d71\u5408\u304c\u9032\u3093\u3067\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5165\u529b\u30b5\u30cb\u30bf\u30a4\u30ba\u306e\u81ea\u52d5\u5316<\/li>\n\n\n\n<li>OWASP TOP 10\u306b\u5bfe\u5fdc\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u306e\u63d0\u4f9b<\/li>\n<\/ul>\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=\"\">@SafeHtml(whitelistType = SafeHtml.WhiteListType.BASIC)\nprivate String userContent;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-37\">AI\/\u6a5f\u68b0\u5b66\u7fd2\u3092\u6d3b\u7528\u3057\u305f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h3>\n\n\n\n<p>\u5c06\u6765\u7684\u306b\u306f\u3001AI\/\u6a5f\u68b0\u5b66\u7fd2\u6280\u8853\u3092\u6d3b\u7528\u3057\u305f\u9ad8\u5ea6\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u624b\u6cd5\u304c\u767b\u5834\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7570\u5e38\u691c\u77e5\u306b\u3088\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff1a\u901a\u5e38\u306e\u30d1\u30bf\u30fc\u30f3\u304b\u3089\u5916\u308c\u305f\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u7684\u306b\u691c\u51fa<\/li>\n\n\n\n<li>\u30d1\u30bf\u30fc\u30f3\u8a8d\u8b58\u3092\u7528\u3044\u305f\u9ad8\u5ea6\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff1a\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u3084\u95a2\u4fc2\u6027\u306e\u691c\u8a3c<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6280\u8853\u306b\u3088\u308a\u3001\u3088\u308a\u67d4\u8edf\u3067\u9069\u5fdc\u6027\u306e\u9ad8\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u304c\u5b9f\u73fe\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-38\">\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306e\u52d5\u5411<\/h3>\n\n\n\n<p>Spring Validation\u306e\u9032\u5316\u306f\u3001\u6d3b\u767a\u306a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306e\u8ca2\u732e\u306b\u3088\u3063\u3066\u63a8\u9032\u3055\u308c\u3066\u3044\u307e\u3059\u3002GitHub\u306eIssues\u3084Discussions\u3001Spring\u793e\u306e\u30ed\u30fc\u30c9\u30de\u30c3\u30d7\u3092\u901a\u3058\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c8\u30d4\u30c3\u30af\u304c\u8b70\u8ad6\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3API\u306e\u3055\u3089\u306a\u308b\u7c21\u7d20\u5316<\/li>\n\n\n\n<li>\u30af\u30e9\u30a6\u30c9\u30cd\u30a4\u30c6\u30a3\u30d6\u74b0\u5883\u3067\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30b0\u30e9\u30d5QL\u306a\u3069\u65b0\u3057\u3044API\u30d1\u30e9\u30c0\u30a4\u30e0\u3078\u306e\u5bfe\u5fdc<\/li>\n<\/ul>\n\n\n\n<p>Spring Validation\u306f\u3001\u3053\u308c\u3089\u306e\u30c8\u30ec\u30f3\u30c9\u3068\u6280\u8853\u306e\u9032\u5316\u306b\u5408\u308f\u305b\u3066\u767a\u5c55\u3092\u7d9a\u3051\u3066\u3044\u304f\u3067\u3057\u3087\u3046\u3002\u958b\u767a\u8005\u306f\u3001\u3053\u308c\u3089\u306e\u65b0\u3057\u3044\u6a5f\u80fd\u3084\u624b\u6cd5\u3092\u7a4d\u6975\u7684\u306b\u53d6\u308a\u5165\u308c\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u3067\u52b9\u7387\u7684\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-39\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001Spring Framework\u306b\u304a\u3051\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u6027\u3068\u3001\u305d\u306e\u5b9f\u88c5\u65b9\u6cd5\u306b\u3064\u3044\u3066\u5305\u62ec\u7684\u306b\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002\u4e3b\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u632f\u308a\u8fd4\u3063\u3066\u307f\u307e\u3057\u3087\u3046\uff1a<\/p>\n\n\n\n<div class=\"wp-block-sgb-message\"><div class=\"memo sng-shadow-0\" style=\"border-radius:0px;background-color:#b4e0fa;color:#009EF3\"><div class=\"memo_ttl dfont\"><span class=\"sng-box-msg__icon\" style=\"background:#009EF3\"><i class=\"far fa-lightbulb\"><\/i><\/span><div class=\"sng-box-msg__title\">\u307e\u3068\u3081<\/div><\/div><div class=\"sng-box-msg__contents\">\n<ol class=\"wp-block-list\">\n<li>Spring Validation\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30fc\u30bf\u6574\u5408\u6027\u3092\u78ba\u4fdd\u3057\u3001\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u3092\u5411\u4e0a\u3055\u305b\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/li>\n\n\n\n<li>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306b\u3088\u308a\u3001\u5ba3\u8a00\u7684\u304b\u3064\u7c21\u6f54\u306b\u30eb\u30fc\u30eb\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306b\u3082\u5bfe\u5fdc\u53ef\u80fd\u3067\u3059\u3002<\/li>\n\n\n\n<li>RESTful API\u306b\u304a\u3044\u3066\u306f\u3001\u9069\u5207\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u304c\u5805\u7262\u6027\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u5411\u4e0a\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u3082\u52b9\u7387\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3068\u306e\u7d71\u5408\u306b\u3088\u308a\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u306e\u4fe1\u983c\u6027\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3092\u901a\u3058\u3066\u3001\u69d8\u3005\u306a\u30b7\u30ca\u30ea\u30aa\u3067\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\u65b9\u6cd5\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<\/li>\n\n\n\n<li>\u6700\u65b0\u30c8\u30ec\u30f3\u30c9\u3068\u3057\u3066Jakarta EE\u7d71\u5408\u3084\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u5bfe\u5fdc\u306a\u3069\u3001Spring Validation\u306e\u4eca\u5f8c\u306e\u767a\u5c55\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n\n\n\n<p>Spring Validation\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u304a\u3044\u3066\u4e0d\u53ef\u6b20\u306a\u8981\u7d20\u3067\u3059\u3002\u672c\u8a18\u4e8b\u3067\u5b66\u3093\u3060\u6982\u5ff5\u3084\u6280\u8853\u3092\u5b9f\u8df5\u306b\u79fb\u3057\u3001\u3088\u308a\u5805\u7262\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u5358\u306a\u308b\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af\u3067\u306f\u306a\u304f\u3001\u30e6\u30fc\u30b6\u30fc\u3068\u306e\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u30c4\u30fc\u30eb\u3067\u3082\u3042\u308a\u307e\u3059\u3002\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3068\u3001\u308f\u304b\u308a\u3084\u3059\u3044\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30eb\u3092\u8a2d\u8a08\u3059\u308b\u3053\u3068\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4eca\u5f8c\u3082 Spring Framework \u3068 Java \u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306e\u9032\u5316\u306b\u6ce8\u76ee\u3057\u3001\u5e38\u306b\u6700\u65b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u53d6\u308a\u5165\u308c\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002Spring \u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084\u3001\u6d3b\u767a\u306a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u30d5\u30a9\u30fc\u30e9\u30e0\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3055\u3089\u306a\u308b\u77e5\u8b58\u306e\u6df1\u5316\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>Spring Validation\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3001\u9ad8\u54c1\u8cea\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u3002\u7686\u69d8\u306e\u958b\u767a\u304c\u3088\u308a\u52b9\u7387\u7684\u3067\u3001\u6210\u529f\u306b\u307f\u3061\u305f\u3082\u306e\u3068\u306a\u308b\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3068\u4fe1\u983c\u6027\u306f\u3001\u73fe\u4ee3\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\u3002Spring Framework\u306f\u3001\u3053\u306e\u8ab2\u984c\u306b\u5bfe\u3057\u3066\u5f37\u529b\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001Spring Framework &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":{"0":"post-306","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-java","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/306","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=306"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/306\/revisions"}],"predecessor-version":[{"id":309,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/306\/revisions\/309"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}