OrderItemquantity@Min(1) annotation on quantity@Max(100) annotation on quantityquantityJump into concepts and practice - no test required
OrderItemquantity@Min(1) annotation on quantity@Max(100) annotation on quantityquantityOrderItem and add a private integer field called quantity.Define the class and then declare the quantity field as an integer.
@Min(1) annotation above the quantity field to ensure the minimum value is 1. Import javax.validation.constraints.Min.Place @Min(1) directly above the quantity field.
@Max(100) annotation above the quantity field to ensure the maximum value is 100. Import javax.validation.constraints.Max.Place @Max(100) directly above the quantity field, below @Min(1).
getQuantity() and a public setter method named setQuantity(int quantity) for the quantity field.Write standard getter and setter methods for the quantity field.
What is the main purpose of using @Min and @Max annotations in Spring Boot?
Which of the following is the correct way to apply @Min and @Max annotations on an integer field age to restrict it between 18 and 65?
public class Person {
// Which is correct?
private int age;
}Given the following Spring Boot entity snippet, what will happen if score is set to 105?
public class GameScore {
@Min(0)
@Max(100)
private int score;
// getters and setters
}Identify the error in this code snippet that uses @Min and @Max:
public class Product {
@Min(1)
@Max(100)
private String quantity;
// getters and setters
}You want to create a Spring Boot model field rating that only accepts values from 1 to 5 inclusive. Which of the following code snippets correctly enforces this using @Min and @Max?