rrader
12/26/2018, 2:25 PMsandwwraith
12/26/2018, 2:25 PMinit
blocks which are executed after deserializationrrader
12/26/2018, 2:28 PMsandwwraith
12/26/2018, 2:29 PMrrader
12/26/2018, 2:32 PMclass Data(val name: String, val age: Int, val email: String)
when we send a json {"email": "<mailto:xyz@xyz.com|xyz@xyz.com>", "name": "A"}
we should return a response where to indicate that age
can not be null and name
size must be greater than 2
Is this possible?sandwwraith
12/26/2018, 2:35 PMValidationException
from init block of Data
, you can write
try {
deserialize(request)
} catch (e: MissingFieldException) {
...
} catch (e: ValidationException) {
...
}
rrader
12/26/2018, 2:36 PMage
field?sandwwraith
12/26/2018, 2:37 PMrrader
12/26/2018, 2:38 PMsandwwraith
12/26/2018, 2:42 PMinit
block, and its execution likely requires already constructed object...