Which annotation is primarily used to declare a field to be validated using JSR-303 Bean Validation?
- @Assert
- @NotNull
- @Valid
- @Validate
The primary annotation used to declare a field to be validated using JSR-303 Bean Validation is @NotNull. This annotation specifies that a field must not be null, and it is commonly used to validate input parameters or form fields to ensure they have values. The other annotations mentioned have different purposes and are not typically used for field validation.
Loading...
Related Quiz
- Which of the following annotations is specifically used for injecting dependencies on setter methods?
- In what cases would you choose constructor injection over setter injection, and why?
- Which annotation is used in Spring Boot to update the cache whenever the underlying data changes?
- In Spring Cloud, how can you enable a service to register itself with Eureka Server?
- How can CSRF protection be customized or disabled in Spring Security?