All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.mths.kava.ValidationScope.kt Maven / Gradle / Ivy

The newest version!
package io.mths.kava

/**
 * Provides a scope to deal with validation logic.
 * Everytime a possible invalid value like an empty Optional or null is accessed,
 * the scope immediately skips the remaining code inside and returns an invalid result.
 */
interface ValidationScope {
    /**
     * This method stops execution of the current [ValidationScope].
     *
     * The Scope returns an invalid result ( like null or an empty [java.util.Optional] ).
     *
     * */
    fun fail(): Nothing

    /**
     * Runs [block] in the current scope and uses validator
     * to return a wrapped result.
     */
    fun  host(
        validator: Validator,
        block: ValidationScope.() -> ScopeType
    ): WrapperType
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy