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

commonMain.pro.felixo.protobuf.schemadocument.validation.ValidationResult.kt Maven / Gradle / Ivy

The newest version!
package pro.felixo.protobuf.schemadocument.validation

import pro.felixo.protobuf.schemadocument.SchemaElement

/**
 * The result of validating a [SchemaElement]. An absence of errors indicates that the element is valid, in which
 * case [isValid] will be `true`.
 */
data class ValidationResult(
    val errors: List
) {
    val isValid: Boolean get() = errors.isEmpty()

    override fun toString(): String = if (isValid)
        "Schema is valid."
    else
        errors.joinToString("\n")

    operator fun plus(other: ValidationResult) = ValidationResult(errors + other.errors)
    operator fun plus(other: List) = ValidationResult(errors + other.flatMap { it.errors })

    companion object {
        val OK = ValidationResult(emptyList())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy