Description
Description
Currently, the MultiSelect
component allows setting a maximum limit for selections using the Limit()
method. However, there's no way to set a minimum number of required selections. Adding a minimum limit would enhance form validation capabilities.
Proposed Solution
Introduce a new method, perhaps called MinLimit(n int)
, to set the minimum number of selections required for a MultiSelect
field.
P.S. AtLeast(n int)
might be great as well.
Example Usage
huh.NewMultiSelect[string]().
Title("Select at least 2 but no more than 4 toppings").
Options(
huh.NewOption("Cheese", "cheese"),
huh.NewOption("Tomatoes", "tomatoes"),
huh.NewOption("Onions", "onions"),
huh.NewOption("Lettuce", "lettuce"),
huh.NewOption("Pickles", "pickles"),
).
MinLimit(2). // New method to set minimum selections
Limit(4). // Existing method for maximum selections
Value(&toppings)