SchemaBuilder
Schema Builder DSL.
Provides a fluent API for registering and validating credential schemas. Supports both JSON Schema and SHACL formats.
Example Usage:
// Register JSON Schema
trustWeave.registerSchema {
id("https://example.edu/schemas/degree")
type("JsonSchemaValidator2018")
jsonSchema {
put("$schema", "http://json-schema.org/draft-07/schema#")
put("type", "object")
put("properties", buildJsonObject {
put("degree", buildJsonObject {
put("type", "object")
put("properties", buildJsonObject {
put("type", buildJsonObject { put("type", "string") })
put("field", buildJsonObject { put("type", "string") })
})
})
})
}
}
// Register SHACL
trustWeave.registerSchema {
id("https://example.edu/schemas/degree-shacl")
type("ShaclValidator2020")
shacl {
put("@context", "https://www.w3.org/ns/shacl#")
put("sh:targetClass", "DegreeCredential")
// ... SHACL shape definition
}
}
// Validate credential
val result = trustWeave.schema("https://example.edu/schemas/degree")
.validate(credential)Content copied to clipboard