-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Open
Labels
status: feedback-providedFeedback has been providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triaged or decided onAn issue we've not yet triaged or decided on
Description
It would be useful if we could access contextual information during the conversion of a request parameter (or similar). That would allow us to influence the conversion result based on for example annotations present at the usage site.
Both Jackson and Hibernate offer comparable mechanisms for this:
- Jackson via
ContextualSerializer(now deprecated, with the functionality included intoValueSerializer) - Hibernate via
DynamicParameterizedType(also deprecated, with the functionality now built directly intoUserType)
Example
@RestController
static class ExampleController {
@RequestMapping(value = "/v1/10-digit-ssn", method = RequestMethod.GET)
public void tenDigitSsn(@RequestParam(name = "ssn") @SSNFormat(length=10) SSN tenDigitSsn) {}
@RequestMapping(value = "/v1/12-digit-ssn", method = RequestMethod.GET)
public void twelveDigitSsn(@RequestParam(name = "ssn") @SSNFormat(length=12) SSN twelveDigitSsn) {}
}What is possible using Jackson;
record Response(@SsnFormat(as = Type.INTEGER) SSN ssn) {}What is possible using Hibernate;
@SSNFormat(as = Type.INTEGER)
@Column(name = "ssn")
SSN ssn;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: feedback-providedFeedback has been providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triaged or decided onAn issue we've not yet triaged or decided on