Contents

maximum(_:)

Enforces a maximum value.

Declaration

static func maximum(_ value: Decimal) -> GenerationGuide<Decimal>

Discussion

Use a maximum generation guide — whose bounds are inclusive — to ensure the model produces a value less than or equal to some maximum value. For example, you can specify that the highest level a character in your game can achieve is 100:

@Generable
struct GameCharacter {
    @Guide(description: "A creative name appropriate for a fantasy RPG character")
    var name: String

    @Guide(description: "A level for the character", .maximum(100))
    var level: Int
}

See Also

Getting the maximum value