SB-6.1-PRE

This commit is contained in:
ItzEmerald committed 2021-02-02 13:50:53 +00:00
1 parent 690169a409
commit 358a25f522
3760 files changed
+300059 -36

No files matched your search

@@ -0,0 +1,3 @@
//# sourceMappingURL=ValidationArguments.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","file":"ValidationArguments.js","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: Object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n \n}"],"sourceRoot":".."}
+37
View File
@@ -0,0 +1,37 @@
/**
* Validation error description.
*/
export class ValidationError {
/**
*
* @param shouldDecorate decorate the message with ANSI formatter escape codes for better readability
* @param hasParent true when the error is a child of an another one
* @param parentPath path as string to the parent of this property
*/
toString(shouldDecorate = false, hasParent = false, parentPath = ``) {
const boldStart = shouldDecorate ? `\x1b[1m` : ``;
const boldEnd = shouldDecorate ? `\x1b[22m` : ``;
const propConstraintFailed = (propertyName) => ` - property ${boldStart}${parentPath}${propertyName}${boldEnd} has failed the following constraints: ${boldStart}${Object.keys(this.constraints).join(`, `)}${boldEnd} \n`;
if (!hasParent) {
return `An instance of ${boldStart}${this.target ? this.target.constructor.name : "an object"}${boldEnd} has failed the validation:\n` +
(this.constraints ? propConstraintFailed(this.property) : ``) +
this.children
.map(childError => childError.toString(shouldDecorate, true, this.property))
.join(``);
}
else {
// we format numbers as array indexes for better readability.
const formattedProperty = Number.isInteger(+this.property) ? `[${this.property}]` : `${parentPath ? `.` : ``}${this.property}`;
if (this.constraints) {
return propConstraintFailed(formattedProperty);
}
else {
return this.children
.map(childError => childError.toString(shouldDecorate, true, `${parentPath}${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AAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAE/H,IAAI,IAAI,CAAC,WAAW,EAAE;gBAClB,OAAO,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;aAClD;iBAAM;gBACH,OAAO,IAAI,CAAC,QAAQ;qBACf,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,EAAE,IAAI,EAAE,GAAG,UAAU,GAAG,iBAAiB,EAAE,CAAG,CAAC;qBACnG,IAAI,CAAC,EAAE,CAAC,CAAC;aACjB;SACJ;IACL,CAAC;CACJ","file":"ValidationError.js","sourcesContent":["/**\n * Validation error description.\n */\nexport class ValidationError {\n\n /**\n * Object that was validated.\n *\n * OPTIONAL - configurable via the ValidatorOptions.validationError.target option\n */\n target?: Object;\n\n /**\n * Object's property that haven't pass validation.\n */\n property: string;\n\n /**\n * Value that haven't pass a validation.\n *\n * OPTIONAL - configurable via the ValidatorOptions.validationError.value option\n */\n value?: any;\n\n /**\n * Constraints that failed validation with error messages.\n */\n constraints?: {\n [type: string]: string\n };\n\n /**\n * Contains all nested validation errors of the property.\n */\n children: ValidationError[];\n\n\n /*\n * A transient set of data passed through to the validation result for response mapping\n */\n contexts?: {\n [type: string]: any\n };\n\n /**\n *\n * @param shouldDecorate decorate the message with ANSI formatter escape codes for better readability\n * @param hasParent true when the error is a child of an another one\n * @param parentPath path as string to the parent of this property\n */\n toString(shouldDecorate: boolean = false, hasParent: boolean = false, parentPath: string = ``): string {\n const boldStart = shouldDecorate ? `\\x1b[1m` : ``;\n const boldEnd = shouldDecorate ? `\\x1b[22m` : ``;\n const propConstraintFailed = (propertyName: string): string => ` - property ${boldStart}${parentPath}${propertyName}${boldEnd} has failed the following constraints: ${boldStart}${Object.keys(this.constraints).join(`, `)}${boldEnd} \\n`;\n\n if (!hasParent) {\n return `An instance of ${boldStart}${this.target ? this.target.constructor.name : \"an object\"}${boldEnd} has failed the validation:\\n` +\n (this.constraints ? propConstraintFailed(this.property) : ``) +\n this.children\n .map(childError => childError.toString(shouldDecorate, true, this.property))\n .join(``);\n } else {\n // we format numbers as array indexes for better readability.\n const formattedProperty = Number.isInteger(+this.property) ? `[${this.property}]` : `${parentPath ? `.` : ``}${this.property}`;\n\n if (this.constraints) {\n return propConstraintFailed(formattedProperty);\n } else {\n return this.children\n .map(childError => childError.toString(shouldDecorate, true, `${parentPath}${formattedProperty}`, ))\n .join(``);\n }\n }\n }\n}\n"],"sourceRoot":".."}
+316
View File
@@ -0,0 +1,316 @@
import { ValidationError } from "./ValidationError";
import { ValidationTypes } from "./ValidationTypes";
import { ValidationUtils } from "./ValidationUtils";
import { isPromise, convertToArray } from "../utils";
import { getMetadataStorage } from "../metadata/MetadataStorage";
/**
* Executes validation over given object.
*/
export class ValidationExecutor {
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
constructor(validator, validatorOptions) {
this.validator = validator;
this.validatorOptions = validatorOptions;
// -------------------------------------------------------------------------
// Properties
// -------------------------------------------------------------------------
this.awaitingPromises = [];
this.ignoreAsyncValidations = false;
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
this.metadataStorage = getMetadataStorage();
}
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
execute(object, targetSchema, validationErrors) {
/**
* If there is no metadata registered it means possibly the dependencies are not flatterned and
* more than one instance is used.
*
* TODO: This needs proper handling, forcing to use the same container or some other proper solution.
*/
if (!this.metadataStorage.hasValidationMetaData) {
console.warn(`No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.`);
}
const groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
const targetMetadatas = this.metadataStorage.getTargetValidationMetadatas(object.constructor, targetSchema, groups);
const groupedMetadatas = this.metadataStorage.groupByPropertyName(targetMetadatas);
if (this.validatorOptions && this.validatorOptions.forbidUnknownValues && !targetMetadatas.length) {
const validationError = new ValidationError();
if (!this.validatorOptions ||
!this.validatorOptions.validationError ||
this.validatorOptions.validationError.target === undefined ||
this.validatorOptions.validationError.target === true)
validationError.target = object;
validationError.value = undefined;
validationError.property = undefined;
validationError.children = [];
validationError.constraints = { unknownValue: "an unknown value was passed to the validate function" };
validationErrors.push(validationError);
return;
}
if (this.validatorOptions && this.validatorOptions.whitelist)
this.whitelist(object, groupedMetadatas, validationErrors);
// General validation
Object.keys(groupedMetadatas).forEach(propertyName => {
const value = object[propertyName];
const definedMetadatas = groupedMetadatas[propertyName].filter(metadata => metadata.type === ValidationTypes.IS_DEFINED);
const metadatas = groupedMetadatas[propertyName].filter(metadata => metadata.type !== ValidationTypes.IS_DEFINED && metadata.type !== ValidationTypes.WHITELIST);
if (value instanceof Promise && metadatas.find(metadata => metadata.type === ValidationTypes.PROMISE_VALIDATION)) {
this.awaitingPromises.push(value.then((resolvedValue) => {
this.performValidations(object, resolvedValue, propertyName, definedMetadatas, metadatas, validationErrors);
}));
}
else {
this.performValidations(object, value, propertyName, definedMetadatas, metadatas, validationErrors);
}
});
}
whitelist(object, groupedMetadatas, validationErrors) {
let notAllowedProperties = [];
Object.keys(object).forEach(propertyName => {
// does this property have no metadata?
if (!groupedMetadatas[propertyName] || groupedMetadatas[propertyName].length === 0)
notAllowedProperties.push(propertyName);
});
if (notAllowedProperties.length > 0) {
if (this.validatorOptions && this.validatorOptions.forbidNonWhitelisted) {
// throw errors
notAllowedProperties.forEach(property => {
const validationError = this.generateValidationError(object, object[property], property);
validationError.constraints = { [ValidationTypes.WHITELIST]: `property ${property} should not exist` };
validationError.children = undefined;
validationErrors.push(validationError);
});
}
else {
// strip non allowed properties
notAllowedProperties.forEach(property => delete object[property]);
}
}
}
stripEmptyErrors(errors) {
return errors.filter(error => {
if (error.children) {
error.children = this.stripEmptyErrors(error.children);
}
if (Object.keys(error.constraints).length === 0) {
if (error.children.length === 0) {
return false;
}
else {
delete error.constraints;
}
}
return true;
});
}
// -------------------------------------------------------------------------
// Private Methods
// -------------------------------------------------------------------------
performValidations(object, value, propertyName, definedMetadatas, metadatas, validationErrors) {
const customValidationMetadatas = metadatas.filter(metadata => metadata.type === ValidationTypes.CUSTOM_VALIDATION);
const nestedValidationMetadatas = metadatas.filter(metadata => metadata.type === ValidationTypes.NESTED_VALIDATION);
const conditionalValidationMetadatas = metadatas.filter(metadata => metadata.type === ValidationTypes.CONDITIONAL_VALIDATION);
const validationError = this.generateValidationError(object, value, propertyName);
validationErrors.push(validationError);
const canValidate = this.conditionalValidations(object, value, conditionalValidationMetadatas);
if (!canValidate) {
return;
}
// handle IS_DEFINED validation type the special way - it should work no matter skipUndefinedProperties/skipMissingProperties is set or not
this.customValidations(object, value, definedMetadatas, validationError);
this.mapContexts(object, value, definedMetadatas, validationError);
if (value === undefined && this.validatorOptions && this.validatorOptions.skipUndefinedProperties === true) {
return;
}
if (value === null && this.validatorOptions && this.validatorOptions.skipNullProperties === true) {
return;
}
if ((value === null || value === undefined) && this.validatorOptions && this.validatorOptions.skipMissingProperties === true) {
return;
}
this.customValidations(object, value, customValidationMetadatas, validationError);
this.nestedValidations(value, nestedValidationMetadatas, validationError.children);
this.mapContexts(object, value, metadatas, validationError);
this.mapContexts(object, value, customValidationMetadatas, validationError);
}
generateValidationError(object, value, propertyName) {
const validationError = new ValidationError();
if (!this.validatorOptions ||
!this.validatorOptions.validationError ||
this.validatorOptions.validationError.target === undefined ||
this.validatorOptions.validationError.target === true)
validationError.target = object;
if (!this.validatorOptions ||
!this.validatorOptions.validationError ||
this.validatorOptions.validationError.value === undefined ||
this.validatorOptions.validationError.value === true)
validationError.value = value;
validationError.property = propertyName;
validationError.children = [];
validationError.constraints = {};
return validationError;
}
conditionalValidations(object, value, metadatas) {
return metadatas
.map(metadata => metadata.constraints[0](object, value))
.reduce((resultA, resultB) => resultA && resultB, true);
}
customValidations(object, value, metadatas, error) {
metadatas.forEach(metadata => {
this.metadataStorage
.getTargetValidatorConstraints(metadata.constraintCls)
.forEach(customConstraintMetadata => {
if (customConstraintMetadata.async && this.ignoreAsyncValidations)
return;
const validationArguments = {
targetName: object.constructor ? object.constructor.name : undefined,
property: metadata.propertyName,
object: object,
value: value,
constraints: metadata.constraints
};
if (!metadata.each || !(value instanceof Array || value instanceof Set || value instanceof Map)) {
const validatedValue = customConstraintMetadata.instance.validate(value, validationArguments);
if (isPromise(validatedValue)) {
const promise = validatedValue.then(isValid => {
if (!isValid) {
const [type, message] = this.createValidationError(object, value, metadata, customConstraintMetadata);
error.constraints[type] = message;
if (metadata.context) {
if (!error.contexts) {
error.contexts = {};
}
error.contexts[type] = Object.assign((error.contexts[type] || {}), metadata.context);
}
}
});
this.awaitingPromises.push(promise);
}
else {
if (!validatedValue) {
const [type, message] = this.createValidationError(object, value, metadata, customConstraintMetadata);
error.constraints[type] = message;
}
}
return;
}
// convert set and map into array
const arrayValue = convertToArray(value);
// Validation needs to be applied to each array item
const validatedSubValues = arrayValue.map((subValue) => customConstraintMetadata.instance.validate(subValue, validationArguments));
const validationIsAsync = validatedSubValues
.some((validatedSubValue) => isPromise(validatedSubValue));
if (validationIsAsync) {
// Wrap plain values (if any) in promises, so that all are async
const asyncValidatedSubValues = validatedSubValues
.map((validatedSubValue) => isPromise(validatedSubValue) ? validatedSubValue : Promise.resolve(validatedSubValue));
const asyncValidationIsFinishedPromise = Promise.all(asyncValidatedSubValues)
.then((flatValidatedValues) => {
const validationResult = flatValidatedValues.every((isValid) => isValid);
if (!validationResult) {
const [type, message] = this.createValidationError(object, value, metadata, customConstraintMetadata);
error.constraints[type] = message;
if (metadata.context) {
if (!error.contexts) {
error.contexts = {};
}
error.contexts[type] = Object.assign((error.contexts[type] || {}), metadata.context);
}
}
});
this.awaitingPromises.push(asyncValidationIsFinishedPromise);
return;
}
const validationResult = validatedSubValues.every((isValid) => isValid);
if (!validationResult) {
const [type, message] = this.createValidationError(object, value, metadata, customConstraintMetadata);
error.constraints[type] = message;
}
});
});
}
nestedValidations(value, metadatas, errors) {
if (value === void 0) {
return;
}
metadatas.forEach(metadata => {
if (metadata.type !== ValidationTypes.NESTED_VALIDATION &&
metadata.type !== ValidationTypes.PROMISE_VALIDATION) {
return;
}
if (value instanceof Array || value instanceof Set || value instanceof Map) {
// Treats Set as an array - as index of Set value is value itself and it is common case to have Object as value
const arrayLikeValue = value instanceof Set ? Array.from(value) : value;
arrayLikeValue.forEach((subValue, index) => {
this.performValidations(value, subValue, index.toString(), [], metadatas, errors);
});
}
else if (value instanceof Object) {
const targetSchema = typeof metadata.target === "string" ? metadata.target : metadata.target.name;
this.execute(value, targetSchema, errors);
}
else {
const error = new ValidationError();
error.value = value;
error.property = metadata.propertyName;
error.target = metadata.target;
const [type, message] = this.createValidationError(metadata.target, value, metadata);
error.constraints = {
[type]: message
};
errors.push(error);
}
});
}
mapContexts(object, value, metadatas, error) {
return metadatas
.forEach(metadata => {
if (metadata.context) {
let customConstraint;
if (metadata.type === ValidationTypes.CUSTOM_VALIDATION) {
const customConstraints = this.metadataStorage.getTargetValidatorConstraints(metadata.constraintCls);
customConstraint = customConstraints[0];
}
const type = this.getConstraintType(metadata, customConstraint);
if (error.constraints[type]) {
if (!error.contexts) {
error.contexts = {};
}
error.contexts[type] = Object.assign((error.contexts[type] || {}), metadata.context);
}
}
});
}
createValidationError(object, value, metadata, customValidatorMetadata) {
const targetName = object.constructor ? object.constructor.name : undefined;
const type = this.getConstraintType(metadata, customValidatorMetadata);
const validationArguments = {
targetName: targetName,
property: metadata.propertyName,
object: object,
value: value,
constraints: metadata.constraints
};
let message = metadata.message || "";
if (!metadata.message &&
(!this.validatorOptions || (this.validatorOptions && !this.validatorOptions.dismissDefaultMessages))) {
if (customValidatorMetadata && customValidatorMetadata.instance.defaultMessage instanceof Function) {
message = customValidatorMetadata.instance.defaultMessage(validationArguments);
}
}
const messageString = ValidationUtils.replaceMessageSpecialTokens(message, validationArguments);
return [type, messageString];
}
getConstraintType(metadata, customValidatorMetadata) {
const type = customValidatorMetadata && customValidatorMetadata.name ? customValidatorMetadata.name : metadata.type;
return type;
}
}
//# sourceMappingURL=ValidationExecutor.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAe3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,SAAoB,EACpB,gBAAmC;QADnC,cAAS,GAAT,SAAS,CAAW;QACpB,qBAAgB,GAAhB,gBAAgB,CAAmB;QAlBvD,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E,qBAAgB,GAAmB,EAAE,CAAC;QACtC,2BAAsB,GAAY,KAAK,CAAC;QAExC,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,oBAAe,GAAG,kBAAkB,EAAE,CAAC;IAQ/C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,OAAO,CAAC,MAAc,EAAE,YAAoB,EAAE,gBAAmC;QAC7E;;;;;WAKG;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE;YAC7C,OAAO,CAAC,IAAI,CAAC,+HAA+H,CAAC,CAAC;SACjJ;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAChF,MAAM,eAAe,GAAG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AAkB,CAAE,MAAW,EACX,KAAU,EAAE,YAAoB,EAChC,gBAAsC,EACtC,SAA+B,EAC/B,gBAAmC;QAE3D,MAAM,yBAAyB,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpH,MAAM,yBAAyB,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpH,MAAM,8BAA8B,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC,sBAAsB,CAAC,CAAC;QAE9H,MAAM,eAAe,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QAClF,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEvC,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC;QAC/F,IAAI,CAAC,WAAW,EAAE;YACd,OAAO;SACV;QAED,2IAA2I;QAC3I,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACzE,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;QAEnE,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,KAAK,IAAI,EAAE;YACxG,OAAO;SACV;QAED,IAAI,KLine truncated
+22
View File
@@ -0,0 +1,22 @@
/**
* Validation types.
*/
export class ValidationTypes {
/**
* Checks if validation type is valid.
*/
static isValid(type) {
return type !== "isValid" &&
type !== "getMessage" &&
Object.keys(this).map(key => this[key]).indexOf(type) !== -1;
}
}
/* system */
ValidationTypes.CUSTOM_VALIDATION = "customValidation"; // done
ValidationTypes.NESTED_VALIDATION = "nestedValidation"; // done
ValidationTypes.PROMISE_VALIDATION = "promiseValidation"; // done
ValidationTypes.CONDITIONAL_VALIDATION = "conditionalValidation"; // done
ValidationTypes.WHITELIST = "whitelistValidation"; // done
ValidationTypes.IS_DEFINED = "isDefined"; // done
//# sourceMappingURL=ValidationTypes.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidationTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAe;IAUxB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,IAAY;QACvB,OAAO,IAAI,KAAK,SAAS;YACrB,IAAI,KAAK,YAAY;YACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;;AAfD,YAAY;AACL,iCAAiB,GAAG,kBAAkB,CAAC,CAAC,OAAO;AAC/C,iCAAiB,GAAG,kBAAkB,CAAC,CAAC,OAAO;AAC/C,kCAAkB,GAAG,mBAAmB,CAAC,CAAC,OAAO;AACjD,sCAAsB,GAAG,uBAAuB,CAAC,CAAC,OAAO;AACzD,yBAAS,GAAG,qBAAqB,CAAC,CAAC,OAAO;AAC1C,0BAAU,GAAG,WAAW,CAAC,CAAC,OAAO","file":"ValidationTypes.js","sourcesContent":["/**\n * Validation types.\n */\nexport class ValidationTypes {\n\n /* system */\n static CUSTOM_VALIDATION = \"customValidation\"; // done\n static NESTED_VALIDATION = \"nestedValidation\"; // done\n static PROMISE_VALIDATION = \"promiseValidation\"; // done\n static CONDITIONAL_VALIDATION = \"conditionalValidation\"; // done\n static WHITELIST = \"whitelistValidation\"; // done\n static IS_DEFINED = \"isDefined\"; // done\n\n /**\n * Checks if validation type is valid.\n */\n static isValid(type: string) {\n return type !== \"isValid\" &&\n type !== \"getMessage\" &&\n Object.keys(this).map(key => (this as any)[key]).indexOf(type) !== -1;\n }\n\n}\n"],"sourceRoot":".."}
+25
View File
@@ -0,0 +1,25 @@
export class ValidationUtils {
static replaceMessageSpecialTokens(message, validationArguments) {
let messageString;
if (message instanceof Function) {
messageString = message(validationArguments);
}
else if (typeof message === "string") {
messageString = message;
}
if (messageString && validationArguments.constraints instanceof Array) {
validationArguments.constraints.forEach((constraint, index) => {
messageString = messageString.replace(new RegExp(`\\$constraint${index + 1}`, "g"), constraint);
});
}
if (messageString && validationArguments.value !== undefined && validationArguments.value !== null && typeof validationArguments.value === "string")
messageString = messageString.replace(/\$value/g, validationArguments.value);
if (messageString)
messageString = messageString.replace(/\$property/g, validationArguments.property);
if (messageString)
messageString = messageString.replace(/\$target/g, validationArguments.targetName);
return messageString;
}
}
//# sourceMappingURL=ValidationUtils.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidationUtils.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAe;IAExB,MAAM,CAAC,2BAA2B,CAAC,OAAuD,EAC9D,mBAAwC;QAEhE,IAAI,aAAqB,CAAC;QAC1B,IAAI,OAAO,YAAY,QAAQ,EAAE;YAC7B,aAAa,GAAI,OAAiD,CAAC,mBAAmB,CAAC,CAAC;SAE3F;aAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YACpC,aAAa,GAAG,OAAiB,CAAC;SACrC;QAED,IAAI,aAAa,IAAI,mBAAmB,CAAC,WAAW,YAAY,KAAK,EAAE;YACnE,mBAAmB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;gBAC1D,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,gBAAgB,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;YACpG,CAAC,CAAC,CAAC;SACN;QAED,IAAI,aAAa,IAAI,mBAAmB,CAAC,KAAK,KAAK,SAAS,IAAI,mBAAmB,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,mBAAmB,CAAC,KAAK,KAAK,QAAQ;YAC/I,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACjF,IAAI,aAAa;YACb,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACvF,IAAI,aAAa;YACb,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAEvF,OAAO,aAAa,CAAC;IACzB,CAAC;CAEJ","file":"ValidationUtils.js","sourcesContent":["import {ValidationArguments} from \"./ValidationArguments\";\n\nexport class ValidationUtils {\n\n static replaceMessageSpecialTokens(message: string|((args: ValidationArguments) => string),\n validationArguments: ValidationArguments): string {\n\n let messageString: string;\n if (message instanceof Function) {\n messageString = (message as (args: ValidationArguments) => string)(validationArguments);\n\n } else if (typeof message === \"string\") {\n messageString = message as string;\n }\n\n if (messageString && validationArguments.constraints instanceof Array) {\n validationArguments.constraints.forEach((constraint, index) => {\n messageString = messageString.replace(new RegExp(`\\\\$constraint${index + 1}`, \"g\"), constraint);\n });\n }\n\n if (messageString && validationArguments.value !== undefined && validationArguments.value !== null && typeof validationArguments.value === \"string\")\n messageString = messageString.replace(/\\$value/g, validationArguments.value);\n if (messageString)\n messageString = messageString.replace(/\\$property/g, validationArguments.property);\n if (messageString)\n messageString = messageString.replace(/\\$target/g, validationArguments.targetName);\n\n return messageString;\n }\n \n}"],"sourceRoot":".."}
+53
View File
@@ -0,0 +1,53 @@
import { ValidationExecutor } from "./ValidationExecutor";
/**
* Validator performs validation of the given object based on its metadata.
*/
export class Validator {
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
/**
* Performs validation of the given object based on decorators or validation schema.
* Common method for `validateOrReject` and `validate` methods.
*/
coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
const object = typeof objectOrSchemaName === "string" ? objectOrValidationOptions : objectOrSchemaName;
const options = typeof objectOrSchemaName === "string" ? maybeValidatorOptions : objectOrValidationOptions;
const schema = typeof objectOrSchemaName === "string" ? objectOrSchemaName : undefined;
const executor = new ValidationExecutor(this, options);
const validationErrors = [];
executor.execute(object, schema, validationErrors);
return Promise.all(executor.awaitingPromises).then(() => {
return executor.stripEmptyErrors(validationErrors);
});
}
/**
* Performs validation of the given object based on decorators or validation schema.
*/
validate(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.
*/
async validateOrReject(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
const errors = await this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions);
if (errors.length)
return Promise.reject(errors);
}
/**
* Performs validation of the given object based on decorators or validation schema.
*/
validateSync(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
const object = typeof objectOrSchemaName === "string" ? objectOrValidationOptions : objectOrSchemaName;
const options = typeof objectOrSchemaName === "string" ? maybeValidatorOptions : objectOrValidationOptions;
const schema = typeof objectOrSchemaName === "string" ? objectOrSchemaName : undefined;
const executor = new ValidationExecutor(this, options);
executor.ignoreAsyncValidations = true;
const validationErrors = [];
executor.execute(object, schema, validationErrors);
return executor.stripEmptyErrors(validationErrors);
}
}
//# sourceMappingURL=Validator.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/Validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAIxD;;GAEG;AACH,MAAM,OAAO,SAAS;IAElB,4E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AM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAaD;;OAEG;IACH,YAAY,CAAC,kBAAiC,EAAE,yBAAmD,EAAE,qBAAwC;QACzI,MAAM,MAAM,GAAG,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,yBAAmC,CAAC,CAAC,CAAC,kBAA4B,CAAC;QAC3H,MAAM,OAAO,GAAG,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,yBAA8C,CAAC;QAChI,MAAM,MAAM,GAAG,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAA4B,CAAC,CAAC,CAAC,SAAS,CAAC;QAEjG,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,QAAQ,CAAC,sBAAsB,GAAG,IAAI,CAAC;QACvC,MAAM,gBAAgB,GAAsB,EAAE,CAAC;QAC/C,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvD,CAAC;CAEJ","file":"Validator.js","sourcesContent":["import {ValidationMetadata} from \"../metadata/ValidationMetadata\";\nimport {ValidationTypes} from \"./ValidationTypes\";\nimport {ValidationError} from \"./ValidationError\";\nimport {ValidatorOptions} from \"./ValidatorOptions\";\nimport {ValidationExecutor} from \"./ValidationExecutor\";\nimport {ValidationOptions} from \"../decorator/ValidationOptions\";\nimport * as validator from \"validator\";\n\n/**\n * Validator performs validation of the given object based on its metadata.\n */\nexport class Validator {\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n\n /**\n * Performs validation of the given object based on decorators or validation schema.\n * Common method for `validateOrReject` and `validate` methods.\n */\n private coreValidate(objectOrSchemaName: Object|string, objectOrValidationOptions: Object|ValidationOptions, maybeValidatorOptions?: ValidatorOptions): Promise<ValidationError[]> {\n const object = typeof objectOrSchemaName === \"string\" ? objectOrValidationOptions as Object : objectOrSchemaName as Object;\n const options = typeof objectOrSchemaName === \"string\" ? maybeValidatorOptions : objectOrValidationOptions as ValidationOptions;\n const schema = typeof objectOrSchemaName === \"string\" ? objectOrSchemaName as string : undefined;\n\n const executor = new ValidationExecutor(this, options);\n const validationErrors: ValidationError[] = [];\n executor.execute(object, schema, validationErrors);\n\n return Promise.all(executor.awaitingPromises).then(() => {\n return executor.stripEmptyErrors(validationErrors);\n });\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs validation of the given object based on decorators used in given object class.\n */\n validate(object: Object, options?: ValidatorOptions): Promise<ValidationError[]>;\n\n /**\n * Performs validation of the given object based on validation schema.\n */\n validate(schemaName: string, object: Object, options?: ValidatorOptions): Promise<ValidationError[]>;\n\n /**\n * Performs validation of the given object based on decorators or validation schema.\n */\n validate(objectOrSchemaName: Object|string, objectOrValidationOptions: Object|ValidationOptions, maybeValidatorOptions?: ValidatorOptions): Promise<ValidationError[]> {\n return this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions);\n }\n\n /**\n * Performs validation of the given object based on decorators used in given object class and reject on error.\n */\n validateOrReject(object: Object, options?: ValidatorOptions): Promise<void>;\n\n /**\n * Performs validation of the given object based on validation schema and reject on error.\n */\n Line truncated
@@ -0,0 +1,3 @@
//# sourceMappingURL=ValidatorConstraintInterface.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidatorConstraintInterface.ts"],"names":[],"mappings":"","file":"ValidatorConstraintInterface.js","sourcesContent":["import {ValidationArguments} from \"./ValidationArguments\";\n/**\n * Custom validators must implement this interface to provide custom validation logic.\n */\nexport interface ValidatorConstraintInterface {\n\n /**\n * Method to be called to perform custom validation over given value.\n */\n validate(value: any, validationArguments?: ValidationArguments): Promise<boolean>|boolean;\n\n /**\n * Gets default message when validation for this constraint fail.\n */\n defaultMessage?(validationArguments?: ValidationArguments): string;\n\n}"],"sourceRoot":".."}
+3
View File
@@ -0,0 +1,3 @@
//# sourceMappingURL=ValidatorOptions.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/validation/ValidatorOptions.ts"],"names":[],"mappings":"","file":"ValidatorOptions.js","sourcesContent":["/**\n * Options passed to validator during validation.\n */\nexport interface ValidatorOptions {\n /**\n * If set to true then validator will skip validation of all properties that are undefined in the validating object.\n */\n skipUndefinedProperties?: boolean;\n\n /**\n * If set to true then validator will skip validation of all properties that are null in the validating object.\n */\n skipNullProperties?: boolean;\n\n /**\n * If set to true then validator will skip validation of all properties that are null or undefined in the validating object.\n */\n skipMissingProperties?: boolean;\n\n /**\n * If set to true validator will strip validated object of any properties that do not have any decorators.\n *\n * Tip: if no other decorator is suitable for your property use @Allow decorator.\n */\n whitelist?: boolean;\n\n /**\n * If set to true, instead of stripping non-whitelisted properties validator will throw an error\n */\n forbidNonWhitelisted?: boolean;\n\n /**\n * Groups to be used during validation of the object.\n */\n groups?: string[];\n\n /**\n * If set to true, the validation will not use default messages.\n * Error message always will be undefined if its not explicitly set.\n */\n dismissDefaultMessages?: boolean;\n\n /**\n * ValidationError special options.\n */\n validationError?: {\n\n /**\n * Indicates if target should be exposed in ValidationError.\n */\n target?: boolean;\n\n /**\n * Indicates if validated value should be exposed in ValidationError.\n */\n value?: boolean;\n\n };\n\n /**\n * Settings true will cause fail validation of unknown objects.\n */\n forbidUnknownValues?: boolean;\n\n}\n"],"sourceRoot":".."}