I'm new to Kotlin/ Java World. So I need a little help to parse an old fashion request in an easy way.
My controller was working perfectly before the new Request.
MyController:
@PostMapping("/create")
@ResponseStatus(OK)
fun create(
@RequestBody @NotEmpty request: PersonRequest,
) = service.create(mapper.toDto(request))
New BodyRequest:
{
"fields": [
{
"id": "name",
"value": "blablabla"
},
{
"id": "phone",
"value": "+1 11111111"
},
{
"id": "birthday",
"value": "2000-01-01"
}
]
}
My Class:
class PersonRequest(
var name: String?,
@field: Pattern(regexp = "blabla")
var phone: String?,
var birthday: LocalDate?
)
Any tips? Thanks!