fixed schema
This commit is contained in:
parent
d3cce3f8cb
commit
ccb7bf3f80
@ -26,7 +26,7 @@ export const actions = {
|
||||
default: async (event) => {
|
||||
const form = await superValidate(event, zod(schema));
|
||||
if (!form.valid) {
|
||||
console.log(form);
|
||||
console.log("form invalid")
|
||||
return fail(400, {
|
||||
form
|
||||
});
|
||||
|
@ -1,20 +1,12 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const domain_regex = /^[a-z0-9\.\-]*$/;
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isValidDomain = key => key === null || domain_regex.test(key);
|
||||
|
||||
export const schema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string().min(4).max(32),
|
||||
primary_color_hex: z.string().length(7),
|
||||
secondary_color_hex: z.string().length(7),
|
||||
text_color_hex: z.string().length(7),
|
||||
domain: z.string().refine(isValidDomain, {
|
||||
domain: z.string().refine((key) => key === null || /^[a-z0-9\.\-]*$/.test(key), {
|
||||
message: "Invalid domain"
|
||||
}).nullable(),
|
||||
use_freebie: z.boolean().default(false),
|
||||
|
Loading…
Reference in New Issue
Block a user