range(_:)
Enforces values fall within a range.
Declaration
static func range(_ range: ClosedRange<Decimal>) -> GenerationGuide<Decimal>Discussion
Bounds are inclusive.
A range generation guide may be used when you want to ensure the model produces a value that falls in some range, such as the cost for an item in a game.
@Generable
struct ShopItem {
@Guide(description: "A creative name for an item sold in a fantasy RPG")
var name: String
@Guide(description: "A cost for the item", .range(0.25...1000))
var cost: Decimal
}