mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
feat: create isNumberFrom1To100 function
This commit is contained in:
parent
8c19c5ba09
commit
dcec2ecdd0
1 changed files with 6 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { z } from 'zod';
|
||||
import { boolean, z } from 'zod';
|
||||
|
||||
/** Get the current time in Nostr format. */
|
||||
const nostrNow = (): number => Math.floor(Date.now() / 1000);
|
||||
|
|
@ -93,12 +93,17 @@ function isURL(value: unknown): boolean {
|
|||
return z.string().url().safeParse(value).success;
|
||||
}
|
||||
|
||||
function isNumberFrom1To100(value: unknown): boolean {
|
||||
return z.coerce.number().int().gte(1).lte(100).safeParse(value).success;
|
||||
}
|
||||
|
||||
export {
|
||||
bech32ToPubkey,
|
||||
dedupeEvents,
|
||||
eventAge,
|
||||
findTag,
|
||||
isNostrId,
|
||||
isNumberFrom1To100,
|
||||
isURL,
|
||||
type Nip05,
|
||||
nostrDate,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue