commonMain.neat.RequiredValidatorBuilders.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neat-validation-jvm Show documentation
Show all versions of neat-validation-jvm Show documentation
A collection library that is built with interoperability in mind
package neat
import neat.internal.RequiredValidator
import kotlin.reflect.KProperty0
fun Validators.required(
message: String = "$label is required, but was null"
): Validator = RequiredValidator(this, message)
fun PropertyValidators
.required(
message: String = "$label is required, but was null"
): Validator {
parent.properties.add(this)
return RequiredValidator(this, message)
}
val KProperty0.required get() = get() ?: throw IllegalArgumentException("$name is required but was null")