nesk / akkurate

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

Support a way to transform (map) a value before validating it #26

Closed nesk closed 1 month ago

nesk commented 6 months ago

It could be useful to transform a value before validating it, for example:

Validator<String> {
    this.map { it.trim('.') }.isNotBlank()
}

By "transforming" the value, the path remains the same, until overridden by withPath.

Essentially, it would work like Optional.map() in Java, or Either.map() with Arrow, but instead of returning an Optional or an Either, it returns a Validatable.