fix(sector-radar): 收紧可复现发布契约

This commit is contained in:
yuxuanhui
2026-08-29 20:36:44 +08:00
parent 8e96e64151
commit 23493fa32f
17 changed files with 520 additions and 86 deletions
@@ -270,9 +270,8 @@ function readRankingRow(value: unknown, index: number): RadarRankingRow {
1,
`${path}.rank_position`,
),
rank_percentile: readNullableNumberInRange(
rank_percentile: readNullablePositiveNumber(
record.rank_percentile,
0,
100,
`${path}.rank_percentile`,
),
@@ -403,16 +402,15 @@ function readNullableInteger(
return readIntegerInRange(value, min, Number.MAX_SAFE_INTEGER, path)
}
function readNullableNumberInRange(
function readNullablePositiveNumber(
value: unknown,
min: number,
max: number,
path: string,
): number | null {
if (value === null) return null
const number = readFiniteNumber(value, path)
if (number < min || number > max) {
throw contractError(path, `must be between ${min} and ${max}`)
if (number <= 0 || number > max) {
throw contractError(path, `must be greater than 0 and at most ${max}`)
}
return number
}