From 95761e2eefdfb20144780de5c8970f8923821af7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 29 Aug 2023 13:28:16 -0500 Subject: [PATCH] schema: add comments --- src/schema.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/schema.ts b/src/schema.ts index 3ecc76a..d32251b 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -11,6 +11,7 @@ function filteredArray(schema: T) { )); } +/** Parses a JSON string into its native type. */ const jsonSchema = z.string().transform((value, ctx) => { try { return JSON.parse(value) as unknown; @@ -20,6 +21,7 @@ const jsonSchema = z.string().transform((value, ctx) => { } }); +/** Parses a Nostr emoji tag. */ const emojiTagSchema = z.tuple([z.literal('emoji'), z.string(), z.string().url()]); /** https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem */ @@ -34,6 +36,7 @@ const decode64Schema = z.string().transform((value, ctx) => { } }); +/** Parses a hashtag, eg `#yolo`. */ const hashtagSchema = z.string().regex(/^\w{1,30}$/); /**