【发布时间】:2018-09-28 12:46:06
【问题描述】:
这是数据类:
data class CreateCommentRequest(
@field:NotNull
@field:NotEmpty
val comment: String,
@field:NotNull
val postId: Long
)
如果我省略了comment 字段,验证会正常失败。
但是如果我不通过postId,像这样:
{
"comment": "hello"
}
验证通过。
如果postId没有通过,如何使验证失败?
附:我使用带有com.fasterxml.jackson.module:jackson-module-kotlin 模块的spring boot 2.0.1,kotlin 版本:1.2.20
【问题讨论】:
标签: validation spring-boot kotlin