javax.validation.constraints.Size#min ( )源码实例Demo

下面列出了javax.validation.constraints.Size#min ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BlogManagePlatform   文件: DefaultModelPlugin.java
private String resolveSize(Field field) {
	Size size = field.getAnnotation(Size.class);
	if (size != null) {
		if (size.min() == 0) {
			return StrUtil.concat("长度不能大于", String.valueOf(size.max()));
		} else {
			return StrUtil.concat("长度不能小于", String.valueOf(size.min()), "且不能大于", String.valueOf(size.max()));
		}
	}
	Length length = field.getAnnotation(Length.class);
	if (length != null) {
		if (length.min() == 0) {
			return StrUtil.concat("长度不能大于", String.valueOf(length.max()));
		} else {
			return StrUtil.concat("长度不能小于", String.valueOf(length.min()), "且不能大于", String.valueOf(length.max()));
		}
	}
	return null;
}
 
/**
 * Determine a given array type's minimum number of items.
 *
 * @param member the field or method to check
 * @return specified minimum number of array items (or null)
 * @see Size
 */
protected Integer resolveArrayMinItems(MemberScope<?, ?> member) {
    if (member.isContainerType()) {
        Size sizeAnnotation = this.getAnnotationFromFieldOrGetter(member, Size.class, Size::groups);
        if (sizeAnnotation != null && sizeAnnotation.min() > 0) {
            // minimum length greater than the default 0 was specified
            return sizeAnnotation.min();
        }
        if (this.getAnnotationFromFieldOrGetter(member, NotEmpty.class, NotEmpty::groups) != null) {
            return 1;
        }
    }
    return null;
}
 
/**
 * Determine a given text type's minimum number of characters.
 *
 * @param member the field or method to check
 * @return specified minimum number of characters (or null)
 * @see Size
 * @see NotEmpty
 * @see NotBlank
 */
protected Integer resolveStringMinLength(MemberScope<?, ?> member) {
    if (member.getType().isInstanceOf(CharSequence.class)) {
        Size sizeAnnotation = this.getAnnotationFromFieldOrGetter(member, Size.class, Size::groups);
        if (sizeAnnotation != null && sizeAnnotation.min() > 0) {
            // minimum length greater than the default 0 was specified
            return sizeAnnotation.min();
        }
        if (this.getAnnotationFromFieldOrGetter(member, NotEmpty.class, NotEmpty::groups) != null
                || this.getAnnotationFromFieldOrGetter(member, NotBlank.class, NotBlank::groups) != null) {
            return 1;
        }
    }
    return null;
}
 
源代码4 项目: rest-schemagen   文件: SizeConstraints.java
public SizeConstraints(Size size) {
    this(size.max(), size.min());
}
 
源代码5 项目: dolphin-platform   文件: SizePropertyValidator.java
@Override
public void initialize(Size constraintAnnotation) {
    this.minSizeValue = constraintAnnotation.min();
    this.maxSizeValue = constraintAnnotation.max();
}
 
 同类方法