validation

Compiler plugin validates the length of string properties using annotations for minimum and maximum length constraints, throwing exceptions when conditions aren't met.

JVMKotlin/NativeWasmJS
GitHub stars1
Authorshfhbd
Dependents0
LicenseApache License 2.0
Creation dateover 2 years ago

Last activity5 days ago
Latest release0.0.18 (about 1 month ago)

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

JVMKotlin/NativeWasmJS
GitHub stars1
Authorshfhbd
Dependents0
LicenseApache License 2.0
Creation dateover 2 years ago

Last activity5 days ago
Latest release0.0.18 (about 1 month ago)

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