我创建了皮肤验证器,但有一个问题。当我收到错误消息时,我可以看到:
status": 400,
"error": "Bad Request",
"errors": [
{
"codes": [
"ValidHours.loginHoursRequest.startHour",
"ValidHours.startHour",
"ValidHours.java.lang.String",
"ValidHours"
],
"arguments": [
{
"codes": [
"loginHoursRequest.startHour",
"startHour"
],
"arguments": null,
"defaultMessage": "startHour",
"code": "startHour"
}
],
"defaultMessage": "Invalid",
"objectName": "loginHoursRequest",
"field": "startHour",
"rejectedValue": "1330",
"bindingFailure": false,
"code": "ValidHours"
}
],
"message": "Validation failed for object='loginHoursRequest'. Error count: 1"
现在,我只想接收“ defaultMessage”,因此它应该是类似的:
status": 400,
"error": "Bad Request",
"errors": "defaultMessage": "Invalid"
我的有效课程:
@MustBeDocumented
@Constraint(validatedBy = [HoursValidation::class])
@Target(
AnnotationTarget.FIELD, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@ReportAsSingleViolation
annotation class ValidHours(
val message: String = "Invalid",
val groups: Array<KClass<out Any>> = [],
val payload: Array<KClass<out Payload>> = []
)