(payload json.RawMessage, maxBytes int, path string)
| 1219 | } |
| 1220 | |
| 1221 | func validateJSONSize(payload json.RawMessage, maxBytes int, path string) error { |
| 1222 | if len(payload) == 0 { |
| 1223 | return nil |
| 1224 | } |
| 1225 | |
| 1226 | trimmed := bytesTrimSpace(payload) |
| 1227 | if !json.Valid(trimmed) { |
| 1228 | return fmt.Errorf("%w: %s must contain valid JSON", ErrValidation, path) |
| 1229 | } |
| 1230 | if len(trimmed) > maxBytes { |
| 1231 | return fmt.Errorf("%w: %s exceeds %d bytes", ErrPayloadTooLarge, path, maxBytes) |
| 1232 | } |
| 1233 | return nil |
| 1234 | } |
| 1235 | |
| 1236 | func validateBoundedCount(count int, maxCount int, label string) error { |
| 1237 | if count < 0 { |
no test coverage detected