blob: 8dcae0d8cfd1dfc115e9234d87ea7f7c5246ba71 [file] [log] [blame]
package types
// BoolValues defines the name and value mappings for ParseBool.
var BoolValues = map[string]interface{}{
"true": true, "yes": true, "on": true, "1": true,
"false": false, "no": false, "off": false, "0": false,
var boolParser = func() *EnumParser {
ep := &EnumParser{}
return ep
// ParseBool parses bool values according to the definitions in BoolValues.
// Parsing is case-insensitive.
func ParseBool(s string) (bool, error) {
v, err := boolParser.Parse(s)
if err != nil {
return false, err
return v.(bool), nil