MCPcopy Index your code
hub / github.com/1Password/for-open-source / ParseNumber

Function ParseNumber

script/validator.go:127–143  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

125}
126
127func ParseNumber(value string) (bool, int, string) {
128 cleanedString := ""
129
130 for _, char := range value {
131 if unicode.IsDigit(char) {
132 cleanedString += string(char)
133 }
134 }
135
136 parsedNumber, err := strconv.Atoi(cleanedString)
137
138 if err != nil {
139 return false, 0, "could not be parsed into a number"
140 }
141
142 return true, parsedNumber, ""
143}
144
145func ParseBool(value string) (bool, bool, string) {
146 parsedBool, err := strconv.ParseBool(value)

Callers 2

intSectionMethod · 0.85
TestParseNumberFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseNumberFunction · 0.68