use of javax.validation.constraints.Positive in project jsonschema-generator by victools.
the class JavaxValidationModule method resolveNumberExclusiveMinimum.
/**
* Determine a number type's minimum (exclusive) value.
*
* @param member the field or method to check
* @return specified exclusive minimum value (or null)
* @see DecimalMin
* @see Positive
*/
protected BigDecimal resolveNumberExclusiveMinimum(MemberScope<?, ?> member) {
DecimalMin decimalMinAnnotation = this.getAnnotationFromFieldOrGetter(member, DecimalMin.class, DecimalMin::groups);
if (decimalMinAnnotation != null && !decimalMinAnnotation.inclusive()) {
return new BigDecimal(decimalMinAnnotation.value());
}
Positive positiveAnnotation = this.getAnnotationFromFieldOrGetter(member, Positive.class, Positive::groups);
if (positiveAnnotation != null) {
return BigDecimal.ZERO;
}
return null;
}
use of javax.validation.constraints.Positive in project jboot by yangfuhai.
the class PositiveInterceptor method intercept.
@Override
public void intercept(Invocation inv) {
Parameter[] parameters = inv.getMethod().getParameters();
for (int index = 0; index < parameters.length; index++) {
Positive positive = parameters[index].getAnnotation(Positive.class);
if (positive != null) {
Object validObject = inv.getArg(index);
if (validObject == null || ((Number) validObject).longValue() <= 0) {
String reason = parameters[index].getName() + " is null or not positive at method: " + ClassUtil.buildMethodString(inv.getMethod());
ValidUtil.throwValidException(parameters[index].getName(), positive.message(), reason);
}
}
}
inv.invoke();
}
Aggregations