mirror of
https://gitee.com/bimuziyan/ccc-obfuscated-code.git
synced 2026-06-02 08:50:52 +08:00
update
This commit is contained in:
68
node_modules/class-validator/esm5/validation/Validator.js
generated
vendored
Normal file
68
node_modules/class-validator/esm5/validation/Validator.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import * as tslib_1 from "tslib";
|
||||
import { ValidationExecutor } from "./ValidationExecutor";
|
||||
/**
|
||||
* Validator performs validation of the given object based on its metadata.
|
||||
*/
|
||||
var Validator = /** @class */ (function () {
|
||||
function Validator() {
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
// Private Properties
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Performs validation of the given object based on decorators or validation schema.
|
||||
* Common method for `validateOrReject` and `validate` methods.
|
||||
*/
|
||||
Validator.prototype.coreValidate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
|
||||
var object = typeof objectOrSchemaName === "string" ? objectOrValidationOptions : objectOrSchemaName;
|
||||
var options = typeof objectOrSchemaName === "string" ? maybeValidatorOptions : objectOrValidationOptions;
|
||||
var schema = typeof objectOrSchemaName === "string" ? objectOrSchemaName : undefined;
|
||||
var executor = new ValidationExecutor(this, options);
|
||||
var validationErrors = [];
|
||||
executor.execute(object, schema, validationErrors);
|
||||
return Promise.all(executor.awaitingPromises).then(function () {
|
||||
return executor.stripEmptyErrors(validationErrors);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Performs validation of the given object based on decorators or validation schema.
|
||||
*/
|
||||
Validator.prototype.validate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
|
||||
return this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions);
|
||||
};
|
||||
/**
|
||||
* Performs validation of the given object based on decorators or validation schema and reject on error.
|
||||
*/
|
||||
Validator.prototype.validateOrReject = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var errors;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions)];
|
||||
case 1:
|
||||
errors = _a.sent();
|
||||
if (errors.length)
|
||||
return [2 /*return*/, Promise.reject(errors)];
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Performs validation of the given object based on decorators or validation schema.
|
||||
*/
|
||||
Validator.prototype.validateSync = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
|
||||
var object = typeof objectOrSchemaName === "string" ? objectOrValidationOptions : objectOrSchemaName;
|
||||
var options = typeof objectOrSchemaName === "string" ? maybeValidatorOptions : objectOrValidationOptions;
|
||||
var schema = typeof objectOrSchemaName === "string" ? objectOrSchemaName : undefined;
|
||||
var executor = new ValidationExecutor(this, options);
|
||||
executor.ignoreAsyncValidations = true;
|
||||
var validationErrors = [];
|
||||
executor.execute(object, schema, validationErrors);
|
||||
return executor.stripEmptyErrors(validationErrors);
|
||||
};
|
||||
return Validator;
|
||||
}());
|
||||
export { Validator };
|
||||
|
||||
//# sourceMappingURL=Validator.js.map
|
||||
Reference in New Issue
Block a user