javax.validation.constraints.Size类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中javax.validation.constraints.Size类的一些代码示例,展示了Size类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Size类的具体详情如下:
包路径:javax.validation.constraints.Size
类名称:Size

Size介绍

暂无

代码示例

代码示例来源:origin: netgloo/spring-boot-samples

@Entity
@Table(name="users")
public class User {
 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 private long id;
 @NotNull
 @Size(min = 3, max = 80)
 private String email;
 @NotNull
 @Size(min = 2, max = 80)
 private String name;

代码示例来源:origin: swagger-api/swagger-core

Size size = (Size) annos.get("javax.validation.constraints.Size");
if ("integer".equals(property.getType()) || "number".equals(property.getType())) {
  property.setMinimum(new BigDecimal(size.min()));
  property.setMaximum(new BigDecimal(size.max()));
} else if (property instanceof StringSchema) {
  StringSchema sp = (StringSchema) property;
  sp.minLength(new Integer(size.min()));
  sp.maxLength(new Integer(size.max()));
} else if (property instanceof ArraySchema) {
  ArraySchema sp = (ArraySchema) property;
  sp.setMinItems(size.min());
  sp.setMaxItems(size.max());

代码示例来源:origin: com.blazebit/blaze-weblink-core-model

@NotNull
@Column(length = RdbmsConstants.NAME_MAX_LENGTH, nullable = false)
@Size(min = 1, max = RdbmsConstants.NAME_MAX_LENGTH)
@Pattern(regexp = "[^/]*", message = "The slash character is not allowed")
public String getName() {
  return name;
}

代码示例来源:origin: prestodb/presto

@NotNull
@Size(min = 1)
public List<ServerAddress> getSeeds()
{
  return seeds;
}

代码示例来源:origin: dzinot/spring-boot-oauth2-jwt

/**
 * 
 * <h2>Permission</h2>
 * 
 * @author Kristijan Georgiev
 * 
 *         Permission entity
 *
 */

@Entity
@Setter
@Getter
@NoArgsConstructor
public class Permission extends BaseIdEntity {

  private static final long serialVersionUID = 1L;

  @NotNull
  @Size(min = 1, max = 60)
  private String name;

}

代码示例来源:origin: xautlx/s2jh4net

@Getter
@Setter
@Access(AccessType.FIELD)
@Entity
@Table(name = "auth_Department")
@MetaData(value = "部门")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  @Size(min = 3)
  @Column(nullable = false, length = 255, unique = true)
  private String code;

代码示例来源:origin: KrailOrg/krail

public class TestEntity implements KrailEntity<Integer, Integer> {
  @NotNull
  @Size(min = 2, max = 14)
  private String firstName;
  @Id
  private Integer id;
  private String lastName;

代码示例来源:origin: com.blazebit/blaze-weblink-core-model

@Id
@Override
@Column(length = RdbmsConstants.NAME_MAX_LENGTH)
@Size(min = 1, max = RdbmsConstants.NAME_MAX_LENGTH)
@Pattern(regexp = "[^/]*", message = "The slash character is not allowed")
public String getId() {
  return id();
}

代码示例来源:origin: LuoLiangDSGA/spring-learning

/**
 * @author luoliang
 * @date 2018/7/8
 */
@Entity
@Data
public class User {
  @Id
  @GeneratedValue
  private Integer id;

  @Size(min = 1, max = 32, message = "Minimum username length: 4 characters,the maximum 32 characters ")
  @Column(unique = true, nullable = false)
  private String username;

  @Size(min = 6, message = "Minimum password length: 8 characters")
  @Column(nullable = false)
  private String password;

  @ElementCollection(fetch = FetchType.EAGER)
  private List<Role> roles;
}

代码示例来源:origin: Impetus/Kundera

@Embeddable
public class PhoneDirectory
  @Column
  private String phoneDirectoryName;
  @Column
  private List<String> contactName;
  @Column
  @Size(message = "The size should be at least equal to one but not more than 2", min = 1, max = 2)
  private Map<String, String> contactMap;

代码示例来源:origin: prestodb/presto

@Size(min = 1)
public Set<HostAddress> getNodes()
{
  return nodes;
}

代码示例来源:origin: Impetus/Kundera

int minSize = ((Size) annotate).min();
int maxSize = ((Size) annotate).max();
if (validationObject != null)
    throwValidationException(((Size) annotate).message());

代码示例来源:origin: hibernate/hibernate-orm

private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) {
  if ( Size.class.equals( descriptor.getAnnotation().annotationType() )
      && String.class.equals( propertyDescriptor.getElementClass() ) ) {
    @SuppressWarnings("unchecked")
    ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor;
    int max = sizeConstraint.getAnnotation().max();
    @SuppressWarnings("unchecked")
    final Iterator<Selectable> itor = property.getColumnIterator();
    if ( itor.hasNext() ) {
      final Selectable selectable = itor.next();
      Column col = (Column) selectable;
      if ( max < Integer.MAX_VALUE ) {
        col.setLength( max );
      }
    }
  }
}

代码示例来源:origin: ebean-orm/ebean

if (notNull != null && isEbeanValidationGroups(notNull.groups())) {
  if (size.max() < Integer.MAX_VALUE) {
   maxSize = Math.max(maxSize, size.max());

代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jsonSchema

private Integer getMinSize(BeanProperty prop) {
  Size ann = getSizeAnnotation(prop);
  if (ann != null) {
    int value = ann.min();
    if (value != 0) {
      return value;
    }
  }
  return null;
}

代码示例来源:origin: com.blazebit/blaze-weblink-core-model

@NotNull
@Column(length = RdbmsConstants.NAME_MAX_LENGTH)
@Size(min = 1, max = RdbmsConstants.NAME_MAX_LENGTH)
@Pattern(regexp = "[^/]*", message = "The slash character is not allowed")
public String getName() {
  return name;
}

代码示例来源:origin: prestodb/presto

@NotNull
@Size(min = 1)
public List<String> getContactPoints()
{
  return contactPoints;
}

代码示例来源:origin: org.openurp.code/openurp-code-edu4j

/**
 * 上下午时段
 *
 * @author xinzhou
 * @see
 */
@Entity(name = "org.openurp.code.edu.model.DayPart")
@Cacheable
@Cache(region = "eams.base", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@industry
public class DayPart extends Code<Integer> {

 private static final long serialVersionUID = 2859213875873154722L;

 @Size(max = 20)
 private String color;

 public String getColor() {
  return color;
 }

 public void setColor(String color) {
  this.color = color;
 }

}

代码示例来源:origin: OpenNMS/opennms

@Column(name="friendlyname", nullable = true)
@Size(min = 0, max = 30)
public String getFriendlyName() {
  return m_friendlyName;
}

代码示例来源:origin: prestodb/presto

@Size(min = 1)
public Set<HostAddress> getNodes()
{
  return nodes;
}

相关文章