Nicola
04/06/2023, 2:20 PMdata class Payment(
val type: PaymentType,
val amount: Float,
val reason: String,
val expiryDate: String,
val code: String,
val lisHoldingCode: String
) {
init {
require(reason.isNotEmpty()) { "Payment reason cannot be empty" }
require(code.isNotEmpty()) { "Payment code cannot be empty" }
require(lisHoldingCode.isNotEmpty()) { "Lis code cannot be empty" }
}
Now I am writing a test to assure that validation rules are respected (ie invalid payload are not accepted).
This happens but message is too vague:
{"message":"Missing/invalid parameters","params":[{"name":"body","type":"body","datatype":"object","required":true,"reason":"Invalid"}]}
I would need a message which clearly states which parameter is wrong, using the message I've putted in the require
How can I do that?
Thanks in advanceNicola
04/06/2023, 2:31 PMval jacksonPaymentRenderRequestDtoLens = Body.auto<Array<PaymentRenderRequestDto>>().toLens()
val dtos = jacksonPaymentRenderRequestDtoLens.extract(req)
Perhaps is it possible to customize these checks in the lens?Nicola
04/06/2023, 2:32 PMAndrew O'Hara
04/06/2023, 3:47 PMNicola
04/06/2023, 3:48 PMAndrew O'Hara
04/06/2023, 3:52 PMNicola
04/06/2023, 4:02 PM