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}$/); /**