
Compiler plugin validates the length of string properties using annotations for minimum and maximum length constraints, throwing exceptions when conditions aren't met.
A compiler plugin to validate the length of String properties.
import app.softwork.validation.MinLength
import app.softwork.validation.MaxLength
class A(
@MinLength(inclusive = 2)
@MaxLength(inclusive = 4)
val a: String,
) {
init {
error("Expected!")
}
}
fun main() {
A(a = "a") // IllegalArgumentException: a.length >= 2, was a
A(a = "abcde") // IllegalArgumentException: a.length <= 4, was abcde
A(a = "abc") // IllegalStateException: Expected!
}The gradle plugin is uploaded to MavenCentral. The runtime supports all targets.
plugins {
id("app.softwork.validation") version "LATEST"
}
repositories {
mavenCentral()
}Apache License 2.0
A compiler plugin to validate the length of String properties.
import app.softwork.validation.MinLength
import app.softwork.validation.MaxLength
class A(
@MinLength(inclusive = 2)
@MaxLength(inclusive = 4)
val a: String,
) {
init {
error("Expected!")
}
}
fun main() {
A(a = "a") // IllegalArgumentException: a.length >= 2, was a
A(a = "abcde") // IllegalArgumentException: a.length <= 4, was abcde
A(a = "abc") // IllegalStateException: Expected!
}The gradle plugin is uploaded to MavenCentral. The runtime supports all targets.
plugins {
id("app.softwork.validation") version "LATEST"
}
repositories {
mavenCentral()
}Apache License 2.0