Closed as not planned
Description
I'm trying to use json-rpc with spring boot and I'm not able to validate model fields.
public class Payload {
@NotNull(message = "amount is mandatory")
private BigDecimal amount;
@NotNull(message = "currency is mandatory")
private String currency;
// setter & getter & constructors ...
}
@JsonRpcService("/generate")
public interface IGenerator {
String generate(@Valid @JsonRpcParam(value = "payload") Payload payload);
}
@AutoJsonRpcServiceImpl
@Component
public class GeneratorImpl implements IGenerator {
@Override
public String generate(@Valid @JsonRpcParam(value = "payload") Payload payload) {
return payload.getAmount() +" "+ payload.getCurrency();
}
}
For that code I would expect if I didn't send amount
or currency
or both I would get ConstraintViolationException.
Is there any way to add validations on the model fields?
Metadata
Metadata
Assignees
Labels
No labels