PositiveInt64 function checks if the given value is 64-bit and positive.
(vals url.Values, def int64, queryParam string)
| 122 | |
| 123 | // PositiveInt64 function checks if the given value is 64-bit and positive. |
| 124 | func (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 |
no test coverage detected