From 92bb5ef865556da7c7c90e7b6862f27d9c4aee95 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 25 Jul 2023 21:13:44 +0200 Subject: [PATCH] support `true` as validation result --- src/utils/internal/validate.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/internal/validate.ts b/src/utils/internal/validate.ts index 5de25dce..52fc0990 100644 --- a/src/utils/internal/validate.ts +++ b/src/utils/internal/validate.ts @@ -3,7 +3,7 @@ import { createError } from "../../error"; // TODO: Consider using similar method of typeschema for external library compatibility // https://github.com/decs/typeschema/blob/v0.1.3/src/assert.ts -export type ValidateResult = T | false | void; +export type ValidateResult = T | true | false | void; export type ValidateFunction = ( data: unknown @@ -18,6 +18,9 @@ export async function validateData( if (res === false) { throw createValidationError(); } + if (res === true) { + return data as T; + } return res ?? (data as T); } catch (error) { throw createValidationError(error);