Questions tagged [struts2-jsr303-plugin]

A JSR-303 Bean Validation Plugin for Struts2. This Plugin works as a bridge between Struts2 request flow and JSR-303 Compliant bean Validator like Hibernate Validator.

Struts2 jsr303 validation plugin's homepage


JSR-303 standardizes validation constraint declaration and metadata for the Java platform. Using this API, you annotate domain model properties with declarative validation constraints and the runtime enforces them. There are a number of built-in constraints you can take advantage of. You may also define your own custom constraints.

To illustrate, consider a simple PersonForm model with two properties:

public class PersonForm {
    private String name;
    private int age;    
}

JSR-303 allows you to define declarative validation constraints against such properties.

public class PersonForm {

    @NotNull
    @Size(max=64)
    private String name;

    @Min(0)
    private int age;

}

When an instance of this class is validated by a JSR-303 Validator, these constraints will be enforced.

A JSR-303 Bean Validation Plguin for Struts2. This Plugin works as a bridge between Struts2 request flow and JSR-303 Compliant bean Validator like Hibernate Validator.

This plugin itself do not provide JSR-303 Specific validationn but will use underlying validator to perform bean validation.

For general information on JSR-303, see the Bean Validation Specification. For information on the specific capabilities of the default reference implementation, see the Hibernate Validator documentation.

4 questions
2
votes
1 answer

What is the best way to handle SonarQube error "javax.validation.constraints.NotNull"

Consider the below code. When I analyze the code for sonar rule, it complains about "javax.validation.constraints.NotNull" but is not initialized in this constructor. I can resolve it by initializing the field with default value ( see example here )…
Shahid
  • 481
  • 1
  • 8
  • 22
1
vote
1 answer

How to provide enum string as value of an attribute?

Enum:- public StatusEnum { MISSING("00"), INVALID("01"); .... } I'm trying to use these strings "MISSING", "INVALID" as an attribute field for JSR Validations:- public class SomePojo{ @NotNull(message = StatusEnum.MISSING.toString()) …
Jerald Baker
  • 1,121
  • 1
  • 12
  • 48
0
votes
2 answers

Javax @Valid @NotBlank not working properly

I have this model - public class Product implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @NotBlank @Column(length = 500,…
Erfan Ahmed
  • 1,536
  • 4
  • 19
  • 34
0
votes
0 answers

How to trigger validation with @Valid annotation in struts2?

I cannot make @javax.validation.Valid annotation work in hibernate,struts2 webapp. Here is my simple Entity with constraints: import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @Entity …