I have an entity:
class SomeInfo( @NotNull @Pattern(regexp = Constraints.EMAIL_REGEX) var value: String) { var id: Long? = null }
And the controller method:
@RequestMapping(value = "/some-info", method = RequestMethod.POST) public Id create(@Valid @RequestBody SomeInfo someInfo) { ... }
@Valid annotation does not work.
It seems that Spring needs a constructor without default parameters, and the fancy code above becomes something ugly (but works) as follows:
class SomeInfo() { constructor(value: String) { this.value = value } @NotNull @Pattern(regexp = Constraints.EMAIL_REGEX) lateinit var value: String var id: Long? = null }
Any good practice to make it less verbose?
Thanks.
source share