Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mingrammer/tyfy
Truthy and falsy text validators
https://github.com/mingrammer/tyfy
falsy truthy validator
Last synced: about 2 months ago
JSON representation
Truthy and falsy text validators
- Host: GitHub
- URL: https://github.com/mingrammer/tyfy
- Owner: mingrammer
- License: mit
- Created: 2019-05-18T06:35:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-18T06:49:41.000Z (over 5 years ago)
- Last Synced: 2024-08-04T01:23:47.372Z (5 months ago)
- Topics: falsy, truthy, validator
- Language: Go
- Size: 3.91 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - tyfy
README
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](https://godoc.org/github.com/mingrammer/tyfy)
```go
IsTruthy("yes")
IsTruthy("no")
// true
// falseIsFalsy("n")
IsFalsy("y")
// true
// false
```You can extend the set of values as needed.
```go
ExtendTruthy([]string{"o"})
ExtendFalsy([]string{"x"})
```## License
MIT