From 14cb87f2248545b78616c1e63a3defbed7d008dd Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Sun, 20 Nov 2022 20:46:13 +0200 Subject: [PATCH] [JAVA-16216] Moved customvalidator from spring-mvc-basic-5 to spring-mvc-basic-3 --- spring-web-modules/spring-mvc-basics-3/README.md | 1 + .../customvalidator/ContactNumberConstraint.java | 0 .../customvalidator/ContactNumberValidator.java | 0 .../baeldung/customvalidator/FieldsValueMatch.java | 0 .../customvalidator/FieldsValueMatchValidator.java | 0 .../baeldung/customvalidator/NewUserController.java | 4 ++-- .../com/baeldung/customvalidator/NewUserForm.java | 2 -- .../com/baeldung/customvalidator/ValidatedPhone.java | 2 -- .../customvalidator/ValidatedPhoneController.java | 0 .../ClassValidationMvcIntegrationTest.java | 0 .../CustomMVCValidatorIntegrationTest.java | 12 ++++++------ spring-web-modules/spring-mvc-basics-5/README.md | 1 - 12 files changed, 9 insertions(+), 13 deletions(-) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/NewUserController.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/NewUserForm.java (96%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java (84%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/main/java/com/baeldung/customvalidator/ValidatedPhoneController.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/test/java/com/baeldung/customvalidator/ClassValidationMvcIntegrationTest.java (100%) rename spring-web-modules/{spring-mvc-basics-5 => spring-mvc-basics-3}/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java (100%) diff --git a/spring-web-modules/spring-mvc-basics-3/README.md b/spring-web-modules/spring-mvc-basics-3/README.md index c9fb14d42c..6c220b23f6 100644 --- a/spring-web-modules/spring-mvc-basics-3/README.md +++ b/spring-web-modules/spring-mvc-basics-3/README.md @@ -6,6 +6,7 @@ This module contains articles about Spring MVC - [How to Read HTTP Headers in Spring REST Controllers](https://www.baeldung.com/spring-rest-http-headers) - [A Custom Data Binder in Spring MVC](https://www.baeldung.com/spring-mvc-custom-data-binder) - [Spring Validation Message Interpolation](https://www.baeldung.com/spring-validation-message-interpolation) +- [Spring MVC Custom Validation](https://www.baeldung.com/spring-mvc-custom-validator) - [Using Enums as Request Parameters in Spring](https://www.baeldung.com/spring-enum-request-param) - [Guide to Flash Attributes in a Spring Web Application](https://www.baeldung.com/spring-web-flash-attributes) - [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserController.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserController.java index c71d862941..040dcf1a85 100644 --- a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserController.java +++ b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserController.java @@ -1,13 +1,13 @@ package com.baeldung.customvalidator; +import javax.validation.Valid; + import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import javax.validation.Valid; - @Controller public class NewUserController { diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserForm.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserForm.java similarity index 96% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserForm.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserForm.java index 0685f0373c..962d22bde7 100644 --- a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/NewUserForm.java +++ b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/NewUserForm.java @@ -1,7 +1,5 @@ package com.baeldung.customvalidator; -import com.baeldung.customvalidator.FieldsValueMatch; - @FieldsValueMatch.List({ @FieldsValueMatch(field = "password", fieldMatch = "verifyPassword", message = "Passwords do not match!"), @FieldsValueMatch(field = "email", fieldMatch = "verifyEmail", message = "Email addresses do not match!") }) public class NewUserForm { private String email; diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java similarity index 84% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java index 25676e49ec..b7650461d2 100644 --- a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java +++ b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ValidatedPhone.java @@ -1,7 +1,5 @@ package com.baeldung.customvalidator; -import com.baeldung.customvalidator.ContactNumberConstraint; - public class ValidatedPhone { @ContactNumberConstraint diff --git a/spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ValidatedPhoneController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ValidatedPhoneController.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/main/java/com/baeldung/customvalidator/ValidatedPhoneController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/customvalidator/ValidatedPhoneController.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/test/java/com/baeldung/customvalidator/ClassValidationMvcIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/customvalidator/ClassValidationMvcIntegrationTest.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/test/java/com/baeldung/customvalidator/ClassValidationMvcIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/customvalidator/ClassValidationMvcIntegrationTest.java diff --git a/spring-web-modules/spring-mvc-basics-5/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java similarity index 100% rename from spring-web-modules/spring-mvc-basics-5/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java index 104915f9ab..827f43c303 100644 --- a/spring-web-modules/spring-mvc-basics-5/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java +++ b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/customvalidator/CustomMVCValidatorIntegrationTest.java @@ -1,5 +1,11 @@ package com.baeldung.customvalidator; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; @@ -7,12 +13,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - public class CustomMVCValidatorIntegrationTest { private MockMvc mockMvc; diff --git a/spring-web-modules/spring-mvc-basics-5/README.md b/spring-web-modules/spring-mvc-basics-5/README.md index e7f39c8ea2..ec91449b0f 100644 --- a/spring-web-modules/spring-mvc-basics-5/README.md +++ b/spring-web-modules/spring-mvc-basics-5/README.md @@ -7,7 +7,6 @@ their own module. The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles: -- [Spring MVC Custom Validation](https://www.baeldung.com/spring-mvc-custom-validator) - [Using Spring @ResponseStatus to Set HTTP Status Code](https://www.baeldung.com/spring-response-status) - [Spring MVC and the @ModelAttribute Annotation](https://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation) - [The HttpMediaTypeNotAcceptableException in Spring MVC](https://www.baeldung.com/spring-httpmediatypenotacceptable)