校验字段属性值
身份证正则表达式
引用包
@NotBlank
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@CreditCardNumber
import org.hibernate.validator.constraints.CreditCardNumber;
@ApiModelProperty("身份证")
@NotBlank(message = "身份证不能为空")
@Pattern(regexp = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)", message = "身份证规则不合法")
private String idNum;
电话正则表达式
@ApiModelProperty("电话")
@Pattern(regexp = "^[1]+\\d{10}$", message = "电话号码规则不合法")
@NotBlank(message = "电话不能为空")
private String phone;
卡号校验
@ApiModelProperty("卡号")
@NotBlank(message = "卡号不能为空")
@CreditCardNumber
private String cardNum;