Validate Your Darlings
This release of Bubbles allows you to handle input validation by defining validation functions that ensure the user is typing text that you expect.
The Validate
API introduces a function that is called every time the input changes to ensure that it is still valid input.
// ValidateFunc is a function that returns an error if the input is invalid.
type ValidateFunc func(string) error
// Validate is a function that checks whether or not the text within the
// input is valid. If it is not valid, the `Err` field will be set to the
// error returned by the function. If the function is not defined, all
// input is considered valid.
Validate ValidateFunc
View the Example Code to see Validate
and ValidateFunc
s work in code.
With these awesome changes introduced by @IllusionMan1212, we can now build forms that ensure all input is valid like a credit card input form!
See the full example to handle input validation in your Bubble Tea apps.
Custom List Status Bar Item Names
Thanks to @wesleimp, lists now have a new function to allow you to set a custom status bar item name. Simply call SetStatusBarItemName
on your list with the singular and plural name of your list item and Bubbles will handle the rest (defaults to "item", "items").
list.SetStatusBarItemName("grocery", "groceries")
This will change the string displayed underneath the Title
of the list, in this case the item name is being used for displaying 2 groceries
.
New Spinners 💫
This release contains two brand new spinners introduced by @wesleimp, check them out:
What's Changed
- Validate Input by @maaslalani in #167
- Custom status bar title by @wesleimp in #169
- New spinners by @wesleimp in #172
New Contributors
- @motemen made their first contribution in #168
- @maaslalani made their first contribution in #167
- @wesleimp made their first contribution in #169
- @vzvu3k6k made their first contribution in #171
- @charlieroth made their first contribution in #177
Full Changelog: v0.11.0...v0.12.0
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.