MCPcopy Create free account
hub / github.com/compozy/agh / validateJSONSize

Function validateJSONSize

internal/task/validate.go:1221–1234  ·  view source on GitHub ↗
(payload json.RawMessage, maxBytes int, path string)

Source from the content-addressed store, hash-verified

1219}
1220
1221func 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
1236func validateBoundedCount(count int, maxCount int, label string) error {
1237 if count < 0 {

Callers 3

ValidateMetadataSizeFunction · 0.85
ValidatePayloadSizeFunction · 0.85
ValidateResultSizeFunction · 0.85

Calls 2

bytesTrimSpaceFunction · 0.85
ValidMethod · 0.45

Tested by

no test coverage detected