Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/pmb/node_modules/webpack-dev-middleware/node_modules/ajv/dist/vocabularies/validation/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const code_1 = require("../code");
const codegen_1 = require("../../compile/codegen");
const util_1 = require("../../compile/util");
const error = {
message: ({ params: { missingProperty } }) => (0, codegen_1.str) `must have required property '${missingProperty}'`,
params: ({ params: { missingProperty } }) => (0, codegen_1._) `{missingProperty: ${missingProperty}}`,
};
const def = {
keyword: "required",
type: "object",
schemaType: "array",
$data: true,
error,
code(cxt) {
const { gen, schema, schemaCode, data, $data, it } = cxt;
const { opts } = it;
if (!$data && schema.length === 0)
return;
const useLoop = schema.length >= opts.loopRequired;
if (it.allErrors)
allErrorsMode();
else
exitOnErrorMode();
if (opts.strictRequired) {
const props = cxt.parentSchema.properties;
const { definedProperties } = cxt.it;
for (const requiredKey of schema) {
if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) {
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
(0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
}
}
}
function allErrorsMode() {
if (useLoop || $data) {
cxt.block$data(codegen_1.nil, loopAllRequired);
}
else {
for (const prop of schema) {
(0, code_1.checkReportMissingProp)(cxt, prop);
}
}
}
function exitOnErrorMode() {
const missing = gen.let("missing");
if (useLoop || $data) {
const valid = gen.let("valid", true);
cxt.block$data(valid, () => loopUntilMissing(missing, valid));
cxt.ok(valid);
}
else {
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
(0, code_1.reportMissingProp)(cxt, missing);
gen.else();
}
}
function loopAllRequired() {
gen.forOf("prop", schemaCode, (prop) => {
cxt.setParams({ missingProperty: prop });
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
});
}
function loopUntilMissing(missing, valid) {
cxt.setParams({ missingProperty: missing });
gen.forOf(missing, schemaCode, () => {
gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
gen.if((0, codegen_1.not)(valid), () => {
cxt.error();
gen.break();
});
}, codegen_1.nil);
}
},
};
exports.default = def;
//# sourceMappingURL=required.js.map |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0042 ]-- |