Refine search
if ("integer".equals(property.getType()) || "number".equals(property.getType())) { Min min = (Min) annos.get("javax.validation.constraints.Min"); property.setMinimum(new BigDecimal(min.value())); if ("integer".equals(property.getType()) || "number".equals(property.getType())) { Max max = (Max) annos.get("javax.validation.constraints.Max"); property.setMaximum(new BigDecimal(max.value())); if (property instanceof NumberSchema) { NumberSchema ap = (NumberSchema) property; ap.setMinimum(new BigDecimal(min.value())); ap.setExclusiveMinimum(!min.inclusive()); if (property instanceof NumberSchema) { NumberSchema ap = (NumberSchema) property; ap.setMaximum(new BigDecimal(max.value())); ap.setExclusiveMaximum(!max.inclusive()); Pattern pattern = (Pattern) annos.get("javax.validation.constraints.Pattern"); if (property instanceof StringSchema) { property.setPattern(pattern.regexp());
protected Long id; @Min(13) @Max(99) protected Integer age; @Size(min = 6, max = 20) protected String password; @Pattern(regexp = "(.+?)@(.+?)") protected String email; @DecimalMin(value = "0.1", inclusive = false) protected Double minBalance; @DecimalMax(value = "1000000", inclusive = false) protected Double maxBalance; @Size(min = 2, max = 10) private List<String> items;
@Override public void initialize(final DecimalMax maxValue) { this.maxValue = new BigDecimal(maxValue.value() ); this.inclusive = maxValue.inclusive(); }
if (null != size) { int minValue = size.min(); int maxValue = size.max(); + " returning null", pattern.regexp()); return null; BigDecimal min = new BigDecimal(-Double.MAX_VALUE); BigDecimal max = new BigDecimal(Double.MAX_VALUE); min = new BigDecimal(decimalMin.value()); if (null != decimalMax) { isFloat = true; max = new BigDecimal(decimalMax.value()); if (null != minAnno) { isRound = true; min = new BigDecimal(minAnno.value()).max(min); if (null != maxAnno) { isRound = true; max = new BigDecimal(maxAnno.value()).min(max);
maxValue = new BigDecimal(decimalMaxAnnotation.value()); minValue = new BigDecimal(decimalMinAnnotation.value()); minValue == null ? null : minValue.byteValue(), maxValue == null ? null : maxValue.byteValue(), random.nextLong()
@Override public final void initialize(DecimalMax constraintAnnotation) { try { max = new BigDecimal(constraintAnnotation.value()); } catch (NumberFormatException e) { throw new IllegalArgumentException(constraintAnnotation.value() + " does not represent a valid BigDecimal format", e); } }
@Override public Double getNumberMaximum(BeanProperty prop) { Max maxAnnotation = prop.getAnnotation(Max.class); if (maxAnnotation != null) { return (double) maxAnnotation.value(); } DecimalMax decimalMaxAnnotation = prop.getAnnotation(DecimalMax.class); return decimalMaxAnnotation != null ? new BigDecimal(decimalMaxAnnotation.value()).doubleValue() : null; }
property.validator(Validator.max(Long.valueOf(a.value()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MAX))); LOGGER.debug( () -> "BeanPropertyBeanValidationPostProcessor: added validator to property [" + property + "] for constraint [" + Max.class.getName() + "] with value [" + a.value() + "]"); }); property.getAnnotation(DecimalMax.class).ifPresent(a -> { property.validator(Validator.max(new BigDecimal(a.value()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MAX))); LOGGER.debug(() -> "BeanPropertyBeanValidationPostProcessor: added validator to property [" + property + "] for constraint [" + DecimalMax.class.getName() + "] with value [" + a.value() + "]"); }); property.validator(Validator.min(Integer.valueOf(a.min()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MIN))); property.validator(Validator.max(Integer.valueOf(a.max()).doubleValue(), ((Builder) property).validator(Validator.pattern(a.regexp(), getValidationMessage(property, a.message(), Validator.ValidationMessage.PATTERN), convertPatternFlags(a.flags())));
long maxValue = maxAnnotation.value(); result = MaxValueRandomizer.getRandomValue(fieldType, maxValue); BigDecimal decimalMaxValue = new BigDecimal(decimalMaxAnnotation.value()); result = MaxValueRandomizer.getRandomValue(fieldType, decimalMaxValue.longValue()); long minValue = minAnnotation.value(); result = MinValueRandomizer.getRandomValue(fieldType, minValue); BigDecimal decimalMinValue = new BigDecimal(decimalMinAnnotation.value()); result = MinValueRandomizer.getRandomValue(fieldType, decimalMinValue.longValue()); int minSize = sizeAnnotation.min(); int maxSize = sizeAnnotation.max(); result = RandomStringUtils.randomAlphabetic(new RandomDataGenerator().nextInt(minSize, maxSize));
private static final long serialVersionUID = -4413530913701110648L; @DecimalMax(value = "9999999999") @NotNull private Long vs; @DecimalMax(value = "9999999999") private Long ss; @DecimalMax(value = "9999") private Short cs; private BigDecimal amt; @Size(max = 512) @Column(length = 512) @Pattern(regexp = "[A-Z\\d]+") @NotNull private String sign; @Size(max = 20) @Column(length = 20) private String desc;
@DecimalMin("1") private BigInteger positionNumber; @XmlElement(name = "Description", required = true) @NotNull @Size(min = 1) private List<String> description; @XmlElement(name = "BillersArticleNumber") @Pattern(regexp = "[0-9 | A-Z | a-z | -_\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df]+") private String billersArticleNumber; @XmlElement(name = "InvoiceRecipientsArticleNumber") @Pattern(regexp = "[0-9 | A-Z | a-z | -_\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df]+") private String invoiceRecipientsArticleNumber; @XmlElement(name = "Quantity", required = true) private Boolean discountFlag; @XmlElement(name = "ReductionRate") @DecimalMax("100") @DecimalMin("0") private BigDecimal reductionRate; @XmlElement(name = "Delivery")
private BigDecimal baseAmount; @XmlElement(name = "Percentage") @DecimalMax("100") @DecimalMin("0") private BigDecimal percentage; @XmlElement(name = "Amount", required = true) @XmlElement(name = "TaxID", required = true) @NotNull @Size(max = 255) private String taxID; @XmlElement(name = "Comment")
@Min(1) private final Integer minValidChars; @Min(1) private final Integer profileDepth; @DecimalMin("0.0") @DecimalMax("100.0") private final Double ambiguityThreshold; @DecimalMin("0.0") @DecimalMax("100.0") private final Double invalidityThreshold; @DecimalMin("1.0") @DecimalMax("99.0") private final Double languageHintWeight; @DecimalMin("1.0") @DecimalMax("100.0") private final Double encodingHintWeight;
@DecimalMax("100") @DecimalMin("0") private BigDecimal value; @XmlAttribute(name = "TaxCode", namespace = "http://www.ebinterface.at/schema/4p1/") @Pattern(regexp = "AT(XXX|[0-9]{3})") private String taxCode;
String regex = ((Pattern) a).regexp(); buffer.append("\nentries[e].setAttribute('ng-pattern', '") .append(regex).append("');"); Size sizeConstraint = (Size) a; int maxLength = sizeConstraint.max(); int minLength = sizeConstraint.min(); String dMin = ((DecimalMin) a).value(); buffer.append("\nentries[e].setAttribute('min', '") .append(dMin).append("');"); String dMax = ((DecimalMax) a).value(); buffer.append("\nentries[e].setAttribute('max', '") .append(dMax).append("');"); long min = ((Min) a).value(); buffer.append("\nentries[e].setAttribute('min', '").append(min) .append("');"); long max = ((Max) a).value(); buffer.append("\nentries[e].setAttribute('max', '").append(max) .append("');");
@DecimalMin("0.0") @DecimalMax("1.0") public double getMemoryRevokingThreshold() { return memoryRevokingThreshold; }
public class ColourRGBAImpl implements ColourRGBA @Max(value = 255, message = "Max 255 for red value in colour") private int red; @Max(value = 255, message = "Max 255 for green value in colour") private int green; @Max(value = 255, message = "Max 255 for blue value in colour") private int blue; @DecimalMax(value = "1.0", message = "Max 1.0 for alpha value in colour") private double alpha;
private AllowableValues createAllowableValuesFromDecimalMinMaxForNumbers( Optional<DecimalMin> decimalMin, Optional<DecimalMax> decimalMax) { AllowableRangeValues myvalues = null; if (decimalMin.isPresent() && decimalMax.isPresent()) { LOG.debug("@DecimalMin+@DecimalMax detected: adding AllowableRangeValues to field "); DecimalMin min = decimalMin.get(); DecimalMax max = decimalMax.get(); myvalues = new AllowableRangeValues(min.value(), !min.inclusive(), max.value(), !max.inclusive()); } else if (decimalMin.isPresent()) { LOG.debug("@DecimalMin detected: adding AllowableRangeValues to field "); DecimalMin min = decimalMin.get(); myvalues = new AllowableRangeValues(min.value(), !min.inclusive(), null, null); } else if (decimalMax.isPresent()) { LOG.debug("@DecimalMax detected: adding AllowableRangeValues to field "); DecimalMax max = decimalMax.get(); myvalues = new AllowableRangeValues(null, null, max.value(), !max.inclusive()); } return myvalues; }
class DecimalMaxDummyEntity { @DecimalMax("101.000000000") BigDecimal bigDecimal; @DecimalMax("1.01E+2") BigInteger bigInteger; @DecimalMax("101") byte bytePrimitive; @DecimalMax("101") short shortPrimitive; @DecimalMax("101") int intPrimitive; @DecimalMax("101") long longPrimitive; @DecimalMax("101") Byte byteObject; @DecimalMax("101") Short shortObject; @DecimalMax("101") Integer intObject; @DecimalMax("101") Long longObject; }