首页>代码>Java Bean Validation和Hibernate Validation简单使用实例,支持自定义标注实现验证功能>/java-bean-validation/src/main/java/com/hellokoding/validation/Product.java
package com.hellokoding.validation;
import javax.validation.constraints.*;
import java.math.BigDecimal;
public class Product {
@NotNull
private Long id;
@ProductCodeExisting
private String code;
@Size(min = 1, max = 10, message = "{Size.name}")
private String name;
@NotNull(message = "must be not null")
private String description;
@Min(value = 1, message = "{Min.price}")
private BigDecimal price;
@Pattern(regexp = "http(s)?://(www)?\\.(.*?)\\.(.*?)")
private String domain;
@Email
private String email;
public Product(Long id, String code, String name, String description, BigDecimal price, String domain, String email) {
this.id = id;
this.code = code;
this.name = name;
this.description = description;
this.price = price;
this.domain = domain;
this.email = email;
}
}
最近下载更多
BestClever LV32
2020年10月19日
最代码官方 LV168
2020年10月18日

最近浏览
