java - How do I use @Valid to validate local variables? -
this followup question here. how add @valid
local variable?
here code class authorizationserver
:
@notblank private string authorizationserverid; @property @indexed(unique = true) @notblank private string authorizationurl; @property(policy = pojomaticpolicy.to_string) @notblank private string clientauthorizationurl; @notblank private string devicerootcert;
this controller:
byte[] bytes = ioutils.tobytearray(request.getinputstream()); string signature = authorization.split(":")[1]; objectmapper mapper = objectmapper(); authorizationserver authorizationserver = mapper.readvalue(bytes, authorizationserver.class);
how validate authorizationserver
against annotations declared in authorizationserver
class?
when tried
@valid authorizationserver authorizationserver = mapper.readvalue(bytes, authorizationserver.class);
i got error @valid not applicable local variable
.
i think exception says all. bean validation not allow validation local variables. validating class state via property validation or can method validation. there no such thing local variable validation.
Comments
Post a Comment