AppFunctionStringValueConstraint


@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.FUNCTIONAnnotationTarget.PROPERTYAnnotationTarget.VALUE_PARAMETER])
public annotation AppFunctionStringValueConstraint


Specifies constraints applied on the string values for return types, parameters, or properties in app functions.

This annotation can be applied to:

  • functions annotated with @AppFunction (to constrain the return value),

  • parameters of @AppFunction,

  • or properties within an @AppFunctionSerializable.

Usage Example:

// Constraining a function return value:
@AppFunction
@AppFunctionStringValueConstraint(enumValues = ["LOW", "MEDIUM", "HIGH"])
fun getPriorityLevel(): String {
// Function body
}

// Constraining a parameter:
@AppFunction
fun setMode(
@AppFunctionStringValueConstraint(enumValues = ["AUTO", "MANUAL"])
mode: String
) {
// Function body
}

// Constraining a property within an AppFunctionSerializable:
@AppFunctionSerializable
data class AppConfig(
@property:AppFunctionStringValueConstraint(enumValues = ["ENABLED", "DISABLED"])
val featureFlag: String
)

Summary

Public constructors

AppFunctionStringValueConstraint(
    @NonNull String[] enumValues,
    @NonNull String pattern,
    @NonNull String format
)

Public methods

final @NonNull String[]

The list of allowed string values for the annotated element.

final @NonNull String

The format description for string values (e.g. "uri").

final @NonNull String

The regex pattern that string values must match.

Public constructors

AppFunctionStringValueConstraint

Added in 1.0.0-alpha11
public AppFunctionStringValueConstraint(
    @NonNull String[] enumValues,
    @NonNull String pattern,
    @NonNull String format
)

Public methods

getEnumValues

public final @NonNull String[] getEnumValues()

The list of allowed string values for the annotated element.

These values are communicated to the agent or framework that interprets or invokes the @AppFunction. If any of the values carry special meaning (e.g., "AUTO" means automatic mode), such meanings should be documented clearly in the corresponding property, parameter, or function return KDoc.

getFormat

public final @NonNull String getFormat()

The format description for string values (e.g. "uri"). An empty string indicates no format description is set.

getPattern

public final @NonNull String getPattern()

The regex pattern that string values must match. An empty string indicates no pattern constraint is applied.