fix(sector-radar): 收紧可复现发布契约
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user