nesk / akkurate

The expressive validation library for Kotlin
https://akkurate.dev
Apache License 2.0
225 stars 9 forks source link

Implement scope control for the DSL #25

Closed nesk closed 4 months ago

nesk commented 6 months ago

https://kotlinlang.org/docs/type-safe-builders.html#scope-control-dslmarker

becomes necessary when writing this kind of code:

labels { // this: Validatable<List<String>>
    hasSizeLowerThanOrEqualTo(3) // OK

    each {
        hasLengthGreaterThanOrEqualTo(1) // OK
        hasSizeGreaterThanOrEqualTo(1) // OK BUT SHOULDN'T BE (applied to the list, not to the string)
    }
}