UNPKG

lakutata

Version:

An IoC-based universal application framework.

136 lines (104 loc) 3.98 kB
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */ import { b as e, D as r } from "../../../../vendor/Package.internal.7.mjs"; import { isAsyncFunction as t } from "node:util/types"; import { InvalidMethodAcceptException as o } from "../../../exceptions/dto/InvalidMethodAcceptException.mjs"; import { InvalidMethodReturnException as n } from "../../../exceptions/dto/InvalidMethodReturnException.mjs"; import { As as a } from "../../helpers/As.mjs"; import "../../../../vendor/Package.internal.3.mjs"; import "./DataValidator.mjs"; import "../../../../vendor/Package.internal.1.mjs"; import "../../../../vendor/Package.internal.2.mjs"; import "../../validation/VLD.mjs"; import "url"; import "util"; import "../../../exceptions/dto/InvalidValueException.mjs"; import "../abstracts/Exception.mjs"; import "../../../../vendor/Package.internal.5.mjs"; import "../../../../vendor/Package.internal.6.mjs"; import "./ThrowWarning.mjs"; import "../../helpers/Templating.mjs"; import "./CamelCase.mjs"; import "../../helpers/NoCase.mjs"; import "../../helpers/DevNull.mjs"; import "../../../../vendor/Package.internal.8.mjs"; import "../../helpers/IsHtml.mjs"; import "../../helpers/IsXML.mjs"; import "../../../constants/DTOMetadataKey.mjs"; import "../../helpers/ObjectConstructor.mjs"; import "../../helpers/ObjectParentConstructors.mjs"; import "../../helpers/ObjectParentConstructor.mjs"; import "../../helpers/ObjectPrototype.mjs"; function s(n, s, p, i) { const m = []; i.forEach(r => m.push(e(a(r)) ? a(r).Schema() : a(r))); p.writable = false; const c = p.value; const l = r.Array().ordered(...m); const y = Array.isArray(m) ? m.length : 1; if (t(c)) { p.value = async function(...e) { const t = e.length - y; try { e = await r.validateAsync(e, l.concat(r.Array().ordered(...new Array(t >= 0 ? t : 0).fill(r.Any())))); } catch (e) { throw new o("Method [{propertyKey}] accept argument {reason}", { propertyKey: s, reason: e.message }); } return c.apply(this, e); }; } else { p.value = function(...e) { const t = e.length - y; try { e = r.validate(e, l.concat(r.Array().ordered(...new Array(t >= 0 ? t : 0).fill(r.Any())))); } catch (e) { throw new o("Method [{propertyKey}] accept argument {reason}", { propertyKey: s, reason: e.message }); } return c.apply(this, e); }; } return p; } function p(o, s, p, i) { const m = e(a(i)) ? a(i).Schema() : a(i); p.writable = false; const c = p.value; if (t(c)) { p.value = async function(...e) { const t = await c.apply(this, e); if (t === undefined) throw new n("Method [{propertyKey}] return undefined", { propertyKey: s }); try { return await r.validateAsync(t, m); } catch (e) { throw new n("Method [{propertyKey}] return value {reason}", { propertyKey: s, reason: e.message }); } }; } else { p.value = function(...e) { const t = c.apply(this, e); if (t === undefined) throw new n("Method [{propertyKey}] return undefined", { propertyKey: s }); try { return r.validate(t, m); } catch (e) { throw new n("Method [{propertyKey}] return value {reason}", { propertyKey: s, reason: e.message }); } }; } return p; } export { s as SetMethodAcceptArgumentsValidator, p as SetMethodReturnValueValidator };