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

commonMain.ru.astrainteractive.klibs.mikro.validation.DefaultValidator.kt Maven / Gradle / Ivy

The newest version!
package ru.astrainteractive.klibs.mikro.validation

import ru.astrainteractive.klibs.mikro.validation.impl.ValidationContextImpl

class DefaultValidator(
    private val context: ValidationContext.() -> Unit
) : Validator {
    override fun validate(value: T): ValidatorResult {
        val validationContext = ValidationContextImpl(value).apply(context)
        val validators = validationContext.create()
        return validators
            .map { it.validate(value) }
            .firstOrNull { it.isFailure }
            ?: ValidatorResult.Success
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy