add audio

This commit is contained in:
Peter Maquiran
2024-08-15 16:34:07 +01:00
parent 8e25733760
commit d1918d6695
10 changed files with 48 additions and 43 deletions
+1 -7
View File
@@ -1,11 +1,5 @@
import { z } from 'zod';
/**
* Regular expression to validate a data URL.
* The pattern matches data URLs that start with `data:`, optionally followed by a media type,
* optionally followed by an encoding (e.g., `base64`), and ending with base64 encoded data.
*/
export const zodDataUrlRegex = /^data:(?:[\w+\/-]+)?(?:[\w+\/-]+)?;base64,[\s\S]*$/;
/**
* Zod schema for validating data URLs.
@@ -19,7 +13,7 @@ export const zodDataUrlRegex = /^data:(?:[\w+\/-]+)?(?:[\w+\/-]+)?;base64,[\s\S]
* console.error('Validation error:', result.error.errors);
* }
*/
export const zodDataUrlSchema = z.string().refine(value => zodDataUrlRegex.test(value), {
export const zodDataUrlSchema = z.string().refine(value => value.startsWith('data:'), {
message: 'Invalid data URL',
});