From 5767d4595ba7a233adf4a13cc7bd7b29f05d2f17 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Fri, 26 Apr 2024 00:14:25 +0800 Subject: [PATCH] fix: #57 fix domain validator must be required problem --- src/client/utils/validator.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/utils/validator.ts b/src/client/utils/validator.ts index 3348f80..aa61629 100644 --- a/src/client/utils/validator.ts +++ b/src/client/utils/validator.ts @@ -19,6 +19,11 @@ export const hostnameValidator: Validator = (rule, value, callback) => { export const domainValidator: Validator = (rule, value, callback) => { try { + if (!rule.required && !value) { + callback(); + return; + } + z.string().regex(hostnameRegex).parse(value); callback(); } catch (err) {