StringPropertyBuilder
Builder for StringPropertyDefinition.
Configures string-type properties with various constraints like format, length, pattern matching, and enumeration. Supports automatic type conversion for default and constant values.
This class is part of the JSON Schema DSL and cannot be instantiated directly. Use PropertyBuilder.string instead within the DSL context.
Basic String Property
property("email") {
string {
description = "Email address"
format = "email"
}
}Content copied to clipboard
String with Length Constraints
property("username") {
string {
minLength = 3
maxLength = 20
pattern = "^[a-zA-Z0-9_]+$"
}
}Content copied to clipboard
String Enum
property("status") {
string {
description = "Current status"
enum = listOf("active", "inactive", "pending")
}
}Content copied to clipboard
String with Default Value
property("name") {
string {
description = "Config name"
default = "default"
}
}Content copied to clipboard
String with Constant Value
property("version") {
string {
description = "API version"
constValue = "v1.0"
}
}Content copied to clipboard