| 2156 | } |
| 2157 | |
| 2158 | func numericContextLimitValue(value any) (int64, bool) { |
| 2159 | switch typed := value.(type) { |
| 2160 | case int64: |
| 2161 | return positiveInt64(typed) |
| 2162 | case int32: |
| 2163 | return positiveInt64(int64(typed)) |
| 2164 | case int: |
| 2165 | return positiveInt64(int64(typed)) |
| 2166 | case float64: |
| 2167 | casted := int64(typed) |
| 2168 | if typed > 0 && float64(casted) == typed { |
| 2169 | return casted, true |
| 2170 | } |
| 2171 | case string: |
| 2172 | parsed, err := strconv.ParseInt(strings.TrimSpace(typed), 10, 64) |
| 2173 | if err == nil { |
| 2174 | return positiveInt64(parsed) |
| 2175 | } |
| 2176 | case json.Number: |
| 2177 | parsed, err := typed.Int64() |
| 2178 | if err == nil { |
| 2179 | return positiveInt64(parsed) |
| 2180 | } |
| 2181 | } |
| 2182 | |
| 2183 | return 0, false |
| 2184 | } |
| 2185 | |
| 2186 | func positiveInt64(value int64) (int64, bool) { |
| 2187 | if value <= 0 { |