32 lines
825 B
Java
Raw Normal View History

2019-09-03 16:27:36 +02:00
package com.baeldung.interpolation;
import java.util.Formatter;
import javax.validation.constraints.Size;
import javax.validation.constraints.Min;
import javax.validation.constraints.DecimalMin;
public class ValidationExamples {
private static final Formatter formatter = new Formatter();
@Size(
2019-09-17 09:07:47 +02:00
min = 5,
max = 14,
message = "The author email '${validatedValue}' must be between {min} and {max} characters long"
2019-09-03 16:27:36 +02:00
)
private String authorEmail;
@Min(
2019-09-17 09:07:47 +02:00
value = 1,
2019-09-26 08:59:52 +02:00
message = "There must be at least {value} test{value > 1 ? 's' : ''} in the test case"
2019-09-03 16:27:36 +02:00
)
private int testCount;
@DecimalMin(
2019-09-17 09:07:47 +02:00
value = "50",
message = "The code coverage ${formatter.format('%1$.2f', validatedValue)} must be higher than {value}%"
2019-09-03 16:27:36 +02:00
)
private double codeCoverage;
}