Skip to content

mingrammer/tyfy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



TyFy

Truthy and falsy text validators




A truthy value is a value that is considered true, and a falsy value is a value that is considered false.

tyfy (short of "truthy and falsy") provides two simple validators for the truthy and falsy text values (string only). It is useful for some programs that accept the human-readable true/false value as input from users, for example, the command line tools with a prompt such as (y/n).

The default values of the truthy and falsy are "1", "true", "t", "yes", "y", "ok" and "0", "false", "f", "no", "n", respectively.

Installation

go get github.com/mingrammer/tyfy

Usage

See details in GoDoc

IsTruthy("yes")
IsTruthy("no")
// true
// false

IsFalsy("n")
IsFalsy("y")
// true
// false

You can extend the set of values as needed.

ExtendTruthy([]string{"o"})
ExtendFalsy([]string{"x"})

License

MIT

About

Truthy and falsy text validators

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages