Validation

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!
}

Install

The gradle plugin is uploaded to MavenCentral. The runtime supports all targets.

plugins {
id("app.softwork.validation") version "LATEST"
}

repositories {
mavenCentral()
}

License

Apache License 2.0

All modules:

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard