mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add penaltyRules validity check
This commit is contained in:
1 file changed
+2
-2
@@ -22,8 +22,8 @@ import { ContestCodeHandler, ContestFileDownloadHandler, ContestScoreboardHandle
|
|||||||
|
|
||||||
const validatePenaltyRules = (input: string) => {
|
const validatePenaltyRules = (input: string) => {
|
||||||
try {
|
try {
|
||||||
yaml.load(input);
|
const res = yaml.load(input);
|
||||||
return true;
|
return typeof res === 'object' && res !== null && Object.keys(res).every((key) => typeof res[key] === 'number');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user