Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
```kotlin title="Kotlin"
import dev.kreuzberg.*
// Generic validator pattern: every IValidator has the same shape.
// `name()` keys the registry, `priority()` orders execution (higher = earlier),
// `should_validate()` is a fast skip-check, and `validate()` throws on failure.
class GenericValidator(
private val pluginName: String,
private val pluginPriority: Int,
private val check: (ExtractionResult, ExtractionConfig) -> Unit,
) : IValidator {
override fun name(): String = pluginName
override fun version(): String = "1.0.0"
override fun initialize() {
// Optional: open resources, load config files, etc.
}
override fun shutdown() {
// Optional: release resources held in initialize().
}
override fun validate(result: ExtractionResult, config: ExtractionConfig) {
check(result, config)
}
override fun should_validate(
_result: ExtractionResult,
_config: ExtractionConfig,
): Boolean = true
override fun priority(): Int = pluginPriority
}
fun registerGenericValidator() {
val validator = GenericValidator(
pluginName = "non-empty-content",
pluginPriority = 200,
) { result, _ ->
require(result.content().isNotBlank()) { "Extracted content is blank" }
}
ValidatorBridge.registerValidator(validator)
}
```