Merge pull request #13066 from panos-kakos/JAVA-16216

[JAVA-16216] Moved customvalidator from spring-mvc-basic-5 to spring-…
This commit is contained in:
kwoyke 2022-11-21 20:20:51 +01:00 committed by GitHub
commit e3c5b9faa5
12 changed files with 9 additions and 13 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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;

View File

@ -1,7 +1,5 @@
package com.baeldung.customvalidator;
import com.baeldung.customvalidator.ContactNumberConstraint;
public class ValidatedPhone {
@ContactNumberConstraint

View File

@ -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;

View File

@ -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)