Tauhid Rehman

08/02/2019, 9:02 PM
hey you guys, need some help. want to use an existing function called
as an extension for a json property on the request itself. the property itself is called
and the below code is the request class:
@NotNull(message = "'bank_account_number' must be provided")
    var bankAccountNumber: String = ""


08/02/2019, 9:43 PM
Not sure if you can do it with annotations, but for this kind of thing, we generally use custom types (eg a subclass of a Maskedstring class) instead of bare strings, and register specific marshallers into the ObjectMapper to automatically handle the masking. This also provides you with small meaningful domain microtypes (such as AccountNumber) which are better practice than using primitives. When applied globally, this approach can have a big multiplier effect on typesafety across the codebase. It also means that you can achieve different effects with different marshallers - for instance you can automatically protect PII by using a masking mapper for Structured Logging and a non-masking mapper for message transmission without changing the types fed into the mapper.