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/wincloud_gateway/node_modules/yup/es/util/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import ValidationError from '../ValidationError';
const once = cb => {
let fired = false;
return (...args) => {
if (fired) return;
fired = true;
cb(...args);
};
};
export default function runTests(options, cb) {
let {
endEarly,
tests,
args,
value,
errors,
sort,
path
} = options;
let callback = once(cb);
let count = tests.length;
const nestedErrors = [];
errors = errors ? errors : [];
if (!count) return errors.length ? callback(new ValidationError(errors, value, path)) : callback(null, value);
for (let i = 0; i < tests.length; i++) {
const test = tests[i];
test(args, function finishTestRun(err) {
if (err) {
// always return early for non validation errors
if (!ValidationError.isError(err)) {
return callback(err, value);
}
if (endEarly) {
err.value = value;
return callback(err, value);
}
nestedErrors.push(err);
}
if (--count <= 0) {
if (nestedErrors.length) {
if (sort) nestedErrors.sort(sort); //show parent errors after the nested ones: name.first, name
if (errors.length) nestedErrors.push(...errors);
errors = nestedErrors;
}
if (errors.length) {
callback(new ValidationError(errors, value, path), value);
return;
}
callback(null, value);
}
});
}
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0043 ]-- |