Package-level declarations

Annotations read by the Konstant KSP processor.

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class ConfigSpec

Marks a data class as a config spec. The KSP processor generates a ConfigLoader.load<Name>() function and a Konstant.init<Name> function for it. Each primary-constructor parameter is a field; a parameter with a default is optional, and a nullable one without a default defaults to null. A parameter whose type is another @ConfigSpec class is loaded as a nested spec, with its keys prefixed by the parameter name (database.url, DATABASE_URL).

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Convert(val with: KClass<*>)

Converts this field with a custom converter: an object implementing io.github.fiol_dev.konstant.core.ValueConverter<T>, where T is the field's type.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Key(val name: String)

Looks this field up under name instead of the key derived from the property name. The name is used exactly as written, in every source and key format, and nested-spec prefixes are not added to it.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class NotBlank

The String must contain a non-whitespace character.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Pattern(val regex: String)

The whole String must match regex.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Range(val min: Double = Double.NEGATIVE_INFINITY, val max: Double = Double.POSITIVE_INFINITY)

The number (Int, Long, Double or Float) must be within min..max, inclusive.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Secret

Hides this field's value as *** in ConfigError values and messages and in ConfigLoader.explain reports. A conversion error's cause becomes invalid value, since parser messages may echo the input. The loaded config object is not changed: its toString is your data class's own and still prints the real value.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Size(val min: Int = 0, val max: Int = Int.MAX_VALUE)

The String's length, or the List, Set or Map's size, must be within min..max, inclusive.