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

commonMain.neat.internal.OptionalValidator.kt Maven / Gradle / Ivy

There is a newer version: 3.0.13
Show newest version
package neat.internal

import neat.CompoundValidators
import neat.Valid
import neat.Validator
import neat.Validators
import neat.Validity
import neat.aggregate

@PublishedApi
internal class OptionalValidator

(val validators: Validators

) : Validator { override val label: String = validators.label override fun validate(value: P?): Validity { if (value == null) return Valid(value) if (validators is CompoundValidators) { return validateRecursively( validators = validators as CompoundValidators, value = value ).aggregate(value) } return validators.functions.values.map { it.function(value) }.aggregate(value) } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy