MCPcopy Index your code
hub / github.com/coder/coder / PositiveInt64

Method PositiveInt64

coderd/httpapi/queryparams.go:124–142  ·  view source on GitHub ↗

PositiveInt64 function checks if the given value is 64-bit and positive.

(vals url.Values, def int64, queryParam string)

Source from the content-addressed store, hash-verified

122
123// PositiveInt64 function checks if the given value is 64-bit and positive.
124func (p *QueryParamParser) PositiveInt64(vals url.Values, def int64, queryParam string) int64 {
125 v, err := parseQueryParam(p, vals, func(v string) (int64, error) {
126 intValue, err := strconv.ParseInt(v, 10, 64)
127 if err != nil {
128 return 0, err
129 }
130 if intValue < 0 {
131 return 0, xerrors.Errorf("value is negative")
132 }
133 return intValue, nil
134 }, def, queryParam)
135 if err != nil {
136 p.Errors = append(p.Errors, codersdk.ValidationError{
137 Field: queryParam,
138 Detail: fmt.Sprintf("Query param %q must be a valid 64-bit positive integer: %s", queryParam, err.Error()),
139 })
140 }
141 return v
142}
143
144// NullableBoolean will return a null sql value if no input is provided.
145// SQLc still uses sql.NullBool rather than the generic type. So converting from

Callers 3

getChatMessagesMethod · 0.95
HandleReadFileMethod · 0.80
HandleReadFileLinesMethod · 0.80

Calls 3

parseQueryParamFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected