Use Number.isSafeInteger to guard against invalid numbers in check-factory
This commit is contained in:
parent
c57960c153
commit
1099b1500e
1 changed files with 4 additions and 6 deletions
|
@ -177,13 +177,11 @@ function parseDialogFormData(formData: HTMLFormElement): Partial<IntermediateGmM
|
||||||
const chosenMinimumFumbleResult = parseInt(formData["minimum-fumble-result"]?.value);
|
const chosenMinimumFumbleResult = parseInt(formData["minimum-fumble-result"]?.value);
|
||||||
const chosenRollMode = formData["roll-mode"]?.value;
|
const chosenRollMode = formData["roll-mode"]?.value;
|
||||||
|
|
||||||
const invalidNumbers = [NaN, Infinity, -Infinity];
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
checkTargetNumber: invalidNumbers.includes(chosenCheckTargetNumber) ? undefined : chosenCheckTargetNumber,
|
checkTargetNumber: Number.isSafeInteger(chosenCheckTargetNumber) ? chosenCheckTargetNumber : undefined,
|
||||||
gmModifier: invalidNumbers.includes(chosenGMModifier) ? undefined : chosenGMModifier,
|
gmModifier: Number.isSafeInteger(chosenGMModifier) ? chosenGMModifier : undefined,
|
||||||
maximumCoupResult: invalidNumbers.includes(chosenMaximumCoupResult) ? undefined : chosenMaximumCoupResult,
|
maximumCoupResult: Number.isSafeInteger(chosenMaximumCoupResult) ? chosenMaximumCoupResult : undefined,
|
||||||
minimumFumbleResult: invalidNumbers.includes(chosenMinimumFumbleResult) ? undefined : chosenMinimumFumbleResult,
|
minimumFumbleResult: Number.isSafeInteger(chosenMinimumFumbleResult) ? chosenMinimumFumbleResult : undefined,
|
||||||
rollMode: Object.values(CONST.DICE_ROLL_MODES).includes(chosenRollMode) ? chosenRollMode : undefined,
|
rollMode: Object.values(CONST.DICE_ROLL_MODES).includes(chosenRollMode) ? chosenRollMode : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue