jvmMain.io.mths.kava.Ensure.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kava-core-jvm Show documentation
Show all versions of kava-core-jvm Show documentation
Core kava functionalities.
The newest version!
package io.mths.kava
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
@OptIn(ExperimentalContracts::class)
fun ValidationScope<*>.ensure(
condition: Boolean
) {
contract {
returns() implies condition
}
if (!condition) {
fail()
}
}
inline fun ValidationScope<*>.ensure(
value: Type,
assertions: Type.() -> Boolean
) {
ensure (value.assertions())
}
inline fun ValidationScope<*>.ensure(
assertions: () -> Boolean
) {
ensure(assertions())
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy