@NotNull,@NotEmpty,@NotBlank cognitive verification

@NotNull,@NotEmpty,@NotBlank cognitive verification

in conclusion:

@NotNull, which means that the object is not null,

@NotEmpty. indicates that the object is not null and the data of the elements in the object cannot be 0,

@NotBlank, which means that the object cannot be null and the number of elements in the object (after using the trim() method) is not 0.

user target audience ,

@NotNull can be applied to different objects, such as Integer, String, and collections. It is generally used in Integer basic data type packaging classes.

@NotEmpty can be used for String, but not for Integer objects, generally used on collection properties

@NotBlank, can only be applied to String objects, generally the same as @NotBlank

For @ ApiModelProperty in allowEmptyValue , it is not for @NotEmpty, and @NotBlank influential.

The page on the swagger corresponding to @ApiModelProperty is displayed, and @NotNull, @NotEmpty, and @NotBlank are validator annotations.

The null in the database is the same as this.

The @DecimalMin annotation does not judge the null value, so it has no effect on @NotNull, @NotEmpty, and @NotBlank.

Another point to say is that when using reference variables, you must verify that they are non-null.

Guess you like

Origin blog.csdn.net/weixin_44767679/article/details/105733131