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,48 @@
```swift title="Swift"
import Kreuzberg
final class MinLengthValidator: Validator {
let minLength: Int
init(minLength: Int = 100) {
self.minLength = minLength
}
func name() -> String {
"min_length_validator"
}
func version() -> String {
"1.0.0"
}
func priority() -> Int32 {
100
}
func validate(result: ExtractionResult, config: ExtractionConfig) -> String {
// Returns JSON-encoded Result<(), String>
let contentLength = result.content().count
if contentLength < minLength {
let message = "Content too short: \(contentLength) < \(minLength)"
return "{\"err\": \"\(message)\"}"
}
return "{\"ok\": null}"
}
func shouldValidate(result: ExtractionResult, config: ExtractionConfig) -> Bool {
true
}
func initialize() -> String {
"{\"ok\": null}"
}
func shutdown() -> String {
"{\"ok\": null}"
}
}
let validator = MinLengthValidator(minLength: 100)
try Kreuzberg.registerValidator(validator)
```