Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../uploads/../../../../instantly.picotech.app/homes/../../wa.picotech.app/public_html/node_modules/path-exists/../duplexify/./.././debug/../domutils/../cheerio/../negotiator/../wrappy/../url/../yargs-parser/../@socket.io/../depd/../mime/../engine.io-parser/../decamelize/../depd/../decamelize/../asynckit/../gopd/../destroy/.././express-validator/src
الملفات الموجودة في هذا الـ Path:
.
..
base.d.ts
base.js
chain
context-builder.d.ts
context-builder.js
context-items
context.d.ts
context.js
express-validator.d.ts
express-validator.js
field-selection.d.ts
field-selection.js
index.d.ts
index.js
matched-data.d.ts
matched-data.js
middlewares
options.d.ts
options.js
utils.d.ts
utils.js
validation-result.d.ts
validation-result.js
مشاهدة ملف: utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runAllChains = exports.toString = exports.bindAll = void 0;
const bindAll = (object) => {
const protoKeys = Object.getOwnPropertyNames(Object.getPrototypeOf(object));
protoKeys.forEach(key => {
const maybeFn = object[key];
if (typeof maybeFn === 'function' && key !== 'constructor') {
object[key] = maybeFn.bind(object);
}
});
return object;
};
exports.bindAll = bindAll;
function toString(value) {
if (value instanceof Date) {
return value.toISOString();
}
else if (value && typeof value === 'object' && value.toString) {
if (typeof value.toString !== 'function') {
return Object.getPrototypeOf(value).toString.call(value);
}
return value.toString();
}
else if (value == null || (isNaN(value) && !value.length)) {
return '';
}
return String(value);
}
exports.toString = toString;
/**
* Runs all validation chains, and returns their results.
*
* If one of them has a request-level bail set, the previous chains will be awaited on so that
* results are not skewed, which can be slow.
* If this same chain also contains errors, no further chains are run.
*/
async function runAllChains(req, chains, runOpts) {
const promises = [];
for (const chain of chains) {
const bails = chain.builder.build().bail;
if (bails) {
await Promise.all(promises);
}
const resultPromise = chain.run(req, runOpts);
promises.push(resultPromise);
if (bails) {
const result = await resultPromise;
if (!result.isEmpty()) {
break;
}
}
}
return Promise.all(promises);
}
exports.runAllChains = runAllChains;