What is the most AGILE APPROACH for checking the Spring-MVC command (speeds up server-side validation implementation)? (Spring-MVC)

I am starting a new Spring-MVC project. Validation is an important function in any project. Thus, I saw many approaches as follows:

  • Spring Verification Interface.

This sounds like a validation of Struts 1.x. In my opinion, this is not clever.

  • Community Verification

I think this is better than the Validator interface

  • An annotation-based bean validation module (Spring)

It looks agile, but I don't know if it supports a collection-based property.

So what is the most AGILE APPROACH to validate your Spring-MVC command? And why? Consider many features, such as a collection-based property, custom validation, etc. If you know / use a different approach in Spring-MVC, feel free to share it.

Yours faithfully,

+3
source share
2 answers

"Agile" means different things to different people :-)

, Hibernate Validator , Hibernate ORM, ONCE ( ) , , - , , 4.0 beta JSR 303, , , .

Validator 3.1 , / ( , , ). 4.0 beta, , .

- .

+4

Spring Validator ? . ?

public void validate(Object target, Errors errors) {

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email",
     "error.blank.email", "Email address is required.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", 
     "error.blank.name", "Name is required");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phone",
     "error.blank.phone", "Phone is required");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "question", 
     "error.blank.question", "Question is required");
}

!

+2

Source: https://habr.com/ru/post/1714642/


All Articles