commonMain.neat.RequiredValidatorBuilders.kt Maven / Gradle / Ivy
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")