java - Spring Validation Annotations - Custom Parameters -
i'm pretty sure know answer question, want ask here in case. i'm working on backend frontend (bff) mobile app using spring boot , restful api.
i'm designing validation errors, , we'd backend return error json structure in these scenarios:
{ "code": "my.unique.code", "message": "user friendly message", "fieldname": "id of field matches front-end" } on request objects i'm using @notnull(message = "my.unique.code") , in restcontrolleradvice, can using code lookup string localization file. issue in coming elegant way populate fieldname.
i can think of 2 solutions:
- create second look-up file matches code fieldname
- create own annotations can add own property think require writing own validators , ton of other work.
are there alternatives else can think of? if not, think i'm going go option 1. thanks!
Comments
Post a Comment