input

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Package input ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cfg *Config) (string, error)

Run is used to prompt an input the user and retrieve the value.

func ValidateAlphanumeric

func ValidateAlphanumeric(s string) error

ValidateAlphanumeric is the validation function to validate an alphanumeric string.

func ValidateDigits

func ValidateDigits(s string) error

ValidateDigits is the validation function to validate a digits only string.

func ValidateEmail

func ValidateEmail(s string) error

ValidateEmail is the validation function to validate an email address string.

func ValidateFloat

func ValidateFloat(s string) error

ValidateFloat is the validation function to validate a float string.

func ValidateInteger

func ValidateInteger(s string) error

ValidateInteger is the validation function to validate an integer string.

func ValidateURL

func ValidateURL(s string) error

ValidateURL is the validation function to validate an URL string.

Types

type Config

type Config struct {
	Message      string
	Placeholder  string
	Initial      string
	ErrorMsg     string
	Password     bool
	ValidateFunc ValidateFunc

	ShowResult bool
	Styles     Styles
}

Config represents the struct to configure the tui input.

type Styles

type Styles struct {
	PrefixIcon       string
	PrefixIconColor  lipgloss.AdaptiveColor
	PromptStyle      lipgloss.Style
	TextStyle        lipgloss.Style
	BackgroundStyle  lipgloss.Style
	PlaceholderStyle lipgloss.Style
	CursorStyle      lipgloss.Style
}

Styles is the struct representing the style configuration options.

func DefaultStyles

func DefaultStyles() (s Styles)

DefaultStyles sets the default styles theme.

type ValidateFunc

type ValidateFunc func(string) error

ValidateFunc is a function that returns an error if the input is invalid.

type ValidationRule

type ValidationRule string

ValidationRule is an alias for string representing a validation rule.

const (
	// Alphanumeric is the string representing the alphanumeric validation rule.
	Alphanumeric ValidationRule = "alphanumeric"
	// DigitsOnly is the string representing the alphanumeric validation rule.
	DigitsOnly ValidationRule = "digits"
	// Integers is the string representing the alphanumeric validation rule.
	Integers ValidationRule = "integers"
	// Floats is the string representing the alphanumeric validation rule.
	Floats ValidationRule = "floats"
	// EmailAddress is the string representing the alphanumeric validation rule.
	EmailAddress ValidationRule = "email"
	// URL is the string representing the alphanumeric validation rule.
	URL ValidationRule = "url"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL