MCPcopy
hub / github.com/1Password/for-open-source / intSection

Method intSection

script/application.go:256–271  ·  view source on GitHub ↗
(sectionName string, required bool, callbacks ...ValidatorCallback)

Source from the content-addressed store, hash-verified

254}
255
256func (a *Application) intSection(sectionName string, required bool, callbacks ...ValidatorCallback) int {
257 value := a.stringSection(sectionName, required, callbacks...)
258
259 // Don't bother proceeding if there's already an error parsing the string
260 if a.validator.HasError(sectionName) || value == "" {
261 return 0
262 }
263
264 pass, number, message := ParseNumber(value)
265 if !pass {
266 a.validator.AddError(sectionName, fmt.Sprintf("%d", number), message)
267 return 0
268 }
269
270 return number
271}
272
273func (a *Application) boolSection(sectionName string, required bool, callbacks ...ValidatorCallback) bool {
274 value := a.stringSection(sectionName, required, callbacks...)

Callers 1

ParseMethod · 0.95

Calls 4

stringSectionMethod · 0.95
ParseNumberFunction · 0.85
HasErrorMethod · 0.80
AddErrorMethod · 0.80

Tested by

no test coverage detected