fix: incorrect schema check for numbers
This commit is contained in:
parent
9c0783c607
commit
aa75fdd63e
@ -17,4 +17,4 @@ export default {
|
|||||||
fetch,
|
fetch,
|
||||||
} satisfies Deno.ServeDefaultExport;
|
} satisfies Deno.ServeDefaultExport;
|
||||||
|
|
||||||
export const VERSION = "0.2.1";
|
export const VERSION = "0.2.2";
|
@ -6,9 +6,9 @@ import type { VideoSnapshotType } from "@core/db/schema.d.ts";
|
|||||||
import { boolean, mixed, number, object, ValidationError } from "yup";
|
import { boolean, mixed, number, object, ValidationError } from "yup";
|
||||||
|
|
||||||
const SnapshotQueryParamsSchema = object({
|
const SnapshotQueryParamsSchema = object({
|
||||||
ps: number().optional().positive(),
|
ps: number().integer().optional().positive(),
|
||||||
pn: number().optional().positive(),
|
pn: number().integer().optional().positive(),
|
||||||
offset: number().optional().positive(),
|
offset: number().integer().optional().positive(),
|
||||||
reverse: boolean().optional(),
|
reverse: boolean().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -16,8 +16,9 @@ const idSchema = mixed().test(
|
|||||||
"is-valid-id",
|
"is-valid-id",
|
||||||
'id must be a string starting with "av" followed by digits, or "BV" followed by 10 alphanumeric characters, or a positive integer',
|
'id must be a string starting with "av" followed by digits, or "BV" followed by 10 alphanumeric characters, or a positive integer',
|
||||||
async (value) => {
|
async (value) => {
|
||||||
if (value && await number().isValid(value)) {
|
if (value && await number().integer().isValid(value)) {
|
||||||
return Number.isInteger(value) && (value as number) > 0;
|
const v = parseInt(value as string);
|
||||||
|
return Number.isInteger(v) && v > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string") {
|
||||||
|
Loading…
Reference in New Issue
Block a user