From 622f4feb2bcc077fac81c9a396cf72a2cb66d1ed Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:21:54 +0900 Subject: [PATCH] chore: added errors --- src/helpers/validator.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/helpers/validator.ts b/src/helpers/validator.ts index ccf1a08..64a5a9c 100644 --- a/src/helpers/validator.ts +++ b/src/helpers/validator.ts @@ -1,13 +1,12 @@ -import { Value } from "@sinclair/typebox/value"; +import { Value, ValueError } from "@sinclair/typebox/value"; import { envSchema, envValidator, PluginSettings, pluginSettingsSchema, pluginSettingsValidator } from "../types"; export function validateAndDecodeSchemas(env: object, rawSettings: object) { - const errors: object[] = []; + const errors: ValueError[] = []; if (!envValidator.test(env)) { for (const error of envValidator.errors(env)) { - const errorMessage = { path: error.path, message: error.message, value: error.value }; - console.error(errorMessage); - errors.push(errorMessage); + console.error(error); + errors.push(error); } } const envDecoded = Value.Decode(envSchema, env || {}); @@ -15,9 +14,8 @@ export function validateAndDecodeSchemas(env: object, rawSettings: object) { const settings = Value.Default(pluginSettingsSchema, rawSettings) as PluginSettings; if (!pluginSettingsValidator.test(settings)) { for (const error of pluginSettingsValidator.errors(settings)) { - const errorMessage = { path: error.path, message: error.message, value: error.value }; - console.error(errorMessage); - errors.push(errorMessage); + console.error(error); + errors.push(error); } }