change .positive() to .nonnegative() !!!
This commit is contained in:
parent
0a9b53bbc1
commit
320d2f493e
|
@ -82,7 +82,7 @@ const relationshipsController: AppController = async (c) => {
|
||||||
|
|
||||||
const accountStatusesQuerySchema = z.object({
|
const accountStatusesQuerySchema = z.object({
|
||||||
pinned: booleanParamSchema.optional(),
|
pinned: booleanParamSchema.optional(),
|
||||||
limit: z.coerce.number().positive().transform((v) => Math.min(v, 40)).catch(20),
|
limit: z.coerce.number().nonnegative().transform((v) => Math.min(v, 40)).catch(20),
|
||||||
exclude_replies: booleanParamSchema.optional(),
|
exclude_replies: booleanParamSchema.optional(),
|
||||||
tagged: z.string().optional(),
|
tagged: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { jsonSchema, safeUrlSchema } from '../schema.ts';
|
||||||
/** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */
|
/** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */
|
||||||
const nostrIdSchema = z.string().regex(/^[0-9a-f]{64}$/);
|
const nostrIdSchema = z.string().regex(/^[0-9a-f]{64}$/);
|
||||||
/** Nostr kinds are positive integers. */
|
/** Nostr kinds are positive integers. */
|
||||||
const kindSchema = z.number().int().positive();
|
const kindSchema = z.number().int().nonnegative();
|
||||||
|
|
||||||
/** Nostr event schema. */
|
/** Nostr event schema. */
|
||||||
const eventSchema = z.object({
|
const eventSchema = z.object({
|
||||||
|
@ -26,9 +26,9 @@ const filterSchema = z.object({
|
||||||
kinds: kindSchema.array().optional(),
|
kinds: kindSchema.array().optional(),
|
||||||
ids: nostrIdSchema.array().optional(),
|
ids: nostrIdSchema.array().optional(),
|
||||||
authors: nostrIdSchema.array().optional(),
|
authors: nostrIdSchema.array().optional(),
|
||||||
since: z.number().int().positive().optional(),
|
since: z.number().int().nonnegative().optional(),
|
||||||
until: z.number().int().positive().optional(),
|
until: z.number().int().nonnegative().optional(),
|
||||||
limit: z.number().int().positive().optional(),
|
limit: z.number().int().nonnegative().optional(),
|
||||||
}).passthrough().and(
|
}).passthrough().and(
|
||||||
z.record(
|
z.record(
|
||||||
z.custom<`#${string}`>((val) => typeof val === 'string' && val.startsWith('#')),
|
z.custom<`#${string}`>((val) => typeof val === 'string' && val.startsWith('#')),
|
||||||
|
@ -75,7 +75,7 @@ const relayInfoDocSchema = z.object({
|
||||||
description: z.string().transform((val) => val.slice(0, 3000)).optional().catch(undefined),
|
description: z.string().transform((val) => val.slice(0, 3000)).optional().catch(undefined),
|
||||||
pubkey: nostrIdSchema.optional().catch(undefined),
|
pubkey: nostrIdSchema.optional().catch(undefined),
|
||||||
contact: safeUrlSchema.optional().catch(undefined),
|
contact: safeUrlSchema.optional().catch(undefined),
|
||||||
supported_nips: z.number().int().positive().array().optional().catch(undefined),
|
supported_nips: z.number().int().nonnegative().array().optional().catch(undefined),
|
||||||
software: safeUrlSchema.optional().catch(undefined),
|
software: safeUrlSchema.optional().catch(undefined),
|
||||||
icon: safeUrlSchema.optional().catch(undefined),
|
icon: safeUrlSchema.optional().catch(undefined),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue