lakutata
Version:
An IoC-based universal application framework.
139 lines (105 loc) • 3.92 kB
JavaScript
import { b as e, D as r } from "../../../../vendor/Package.2.mjs";
import { isAsyncFunction as t } from "node:util/types";
import { InvalidMethodAcceptException as o } from "../../../exceptions/dto/InvalidMethodAcceptException.mjs";
import { InvalidMethodReturnException as a } from "../../../exceptions/dto/InvalidMethodReturnException.mjs";
import { As as n } from "../../helpers/As.mjs";
import "../../../../vendor/Package.1.mjs";
import "./DataValidator.mjs";
import "../../../../vendor/Package.4.mjs";
import "../../../../vendor/Package.5.mjs";
import "../../validation/VLD.mjs";
import "../../../../vendor/Package.11.mjs";
import "url";
import "../../../../vendor/Package.10.mjs";
import "util";
import "../../../exceptions/dto/InvalidValueException.mjs";
import "../abstracts/Exception.mjs";
import "./BasicInfo.mjs";
import "../../../../vendor/Package.6.mjs";
import "../../../../vendor/Package.7.mjs";
import "./ThrowWarning.mjs";
import "../../helpers/Templating.mjs";
import "./CamelCase.mjs";
import "../../helpers/NoCase.mjs";
import "../../../../vendor/Package.9.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(a, s, p, i) {
const m = [];
i.forEach((r => m.push(e(n(r)) ? n(r).Schema() : n(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(n(i)) ? n(i).Schema() : n(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 a("Method [{propertyKey}] return undefined", {
propertyKey: s
});
try {
return await r.validateAsync(t, m);
} catch (e) {
throw new a("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 a("Method [{propertyKey}] return undefined", {
propertyKey: s
});
try {
return r.validate(t, m);
} catch (e) {
throw new a("Method [{propertyKey}] return value {reason}", {
propertyKey: s,
reason: e.message
});
}
};
}
return p;
}
export { s as SetMethodAcceptArgumentsValidator, p as SetMethodReturnValueValidator };