com.github.erosb.jsonsKema.DependentRequired.kt Maven / Gradle / Ivy
Show all versions of json-sKema Show documentation
package com.github.erosb.jsonsKema
data class DependentRequiredSchema(val dependentRequired: Map>, override val location: SourceLocation) : Schema(location) {
override fun accept(visitor: SchemaVisitor
): P? = visitor.visitDependentRequiredSchema(this)
}
internal val dependentRequiredLoader: KeywordLoader = { ctx ->
val dependentRequired = ctx.keywordValue.requireObject().properties
.map { it.key.value to it.value.requireArray().elements.map { it.requireString().value } }
.toMap()
DependentRequiredSchema(dependentRequired, ctx.location)
}
data class DependentRequiredValidationFailure(
val presentKey: String,
val missingKeys: Set,
override val schema: DependentRequiredSchema,
override val instance: IJsonObj,
override val dynamicPath: JsonPointer
) : ValidationFailure("property $presentKey is present in the object but the following properties are missing: ${missingKeys.joinToString(", ")}", schema, instance, Keyword.DEPENDENT_REQUIRED)