core: parseFloat: allow 0

This commit is contained in:
undefined committed 2021-07-24 12:00:32 +08:00
1 parent 44de90bcab
commit c67d626abe
2 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.29.36", "version": "2.29.37",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+1 -4
View File
@@ -83,10 +83,7 @@ export const Types: Types = {
Int: [(v) => parseInt(v, 10), (v) => isSafeInteger(parseInt(v, 10))], Int: [(v) => parseInt(v, 10), (v) => isSafeInteger(parseInt(v, 10))],
UnsignedInt: [(v) => parseInt(v, 10), (v) => parseInt(v, 10) >= 0], UnsignedInt: [(v) => parseInt(v, 10), (v) => parseInt(v, 10) >= 0],
PositiveInt: [(v) => parseInt(v, 10), (v) => parseInt(v, 10) > 0], PositiveInt: [(v) => parseInt(v, 10), (v) => parseInt(v, 10) > 0],
Float: [(v) => parseFloat(v), (v) => { Float: [(v) => +v, (v) => Number.isFinite(+v)],
const t = parseFloat(v);
return t && !Number.isNaN(t) && Number.isFinite(t);
}],
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
ObjectID: [(v) => new ObjectID(v), ObjectID.isValid], ObjectID: [(v) => new ObjectID(v), ObjectID.isValid],
Boolean: [(v) => !!v, null, true], Boolean: [(v) => !!v, null, true],