The urge to build DSLs... On a little project, bu...
# codereview
g
The urge to build DSLs... On a little project, building some validation for GRPC messages. currently
Copy code
private val staticValidations = ContextFreeMessageValidator().apply {
        addValidation<AnchorLocationDTO> {
            require(it.occurance >= 1) { "Must have positive occurrence" }
        }
and maybe a few dozen more such validations. but what if I wrote a slick DSL:
Copy code
private val dslTest = contextFreeMessageValidator {
    + { message: AnchorLocationDTO ->
        require(message.occurance >= 1) { "Must have positive occurrence" }
    }
}
its so pretty... but no... I must resist, nobody else on my project will have any idea wtf thats doing...
f
Do it, I'm looking for my first opportunity to write one
j
Akkurare is a cool library for validation, maybe it can help you https://github.com/nesk/akkurate
👍 1
c
that looks nice!