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"
}
}

String with Length Constraints

property("username") {
string {
minLength = 3
maxLength = 20
pattern = "^[a-zA-Z0-9_]+$"
}
}

String Enum

property("status") {
string {
description = "Current status"
enum = listOf("active", "inactive", "pending")
}
}

String with Default Value

property("name") {
string {
description = "Config name"
default = "default"
}
}

String with Constant Value

property("version") {
string {
description = "API version"
constValue = "v1.0"
}
}

See also

Properties

Link copied to clipboard

Constant value for this property.

Link copied to clipboard
var default: Any?

Default value for this property.

Link copied to clipboard

Human-readable description of this property.

Link copied to clipboard

List of allowed string values (enumeration).

Link copied to clipboard

Format specification (e.g., "email", "uri", "date-time", "uuid").

Link copied to clipboard

Maximum string length constraint.

Link copied to clipboard

Minimum string length constraint.

Link copied to clipboard

Whether null values are allowed.

Link copied to clipboard

Regular expression pattern the string must match.

Link copied to clipboard

The JSON Schema type. Always "string" for this builder.

Functions

Link copied to clipboard