@composer-js/core
Advanced tools
Comparing version 6.0.0-rc.19 to 6.0.0-rc.20
@@ -33,2 +33,3 @@ "use strict"; | ||
__exportStar(require("./UserUtils"), exports); | ||
__exportStar(require("./ValidationUtils"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -36,4 +36,9 @@ "use strict"; | ||
const validator = Reflect.getMetadata("cjs:validator", metadataObj, member); | ||
if (validator && obj[member] && !validator(obj[member])) { | ||
throw new Error(`Property ${member} is invalid.`); | ||
if (validator && obj[member]) { | ||
try { | ||
obj[member] = validator(obj[member]); | ||
} | ||
catch (err) { | ||
throw new Error(`Property ${member} is invalid. ${err.message}`); | ||
} | ||
} | ||
@@ -40,0 +45,0 @@ // If recursion is requested validate the child object |
@@ -43,2 +43,10 @@ import "reflect-metadata"; | ||
/** | ||
* A function used to validate a property value. | ||
* | ||
* @param value The value to validate. | ||
* @returns The validated value to assign to the property. | ||
* @throws An exception if the value cannot be validated. | ||
*/ | ||
export type ValidatorFunction = (value: any) => any; | ||
/** | ||
* Apply this to a property to specify the function that will be used to perform validation of the value. | ||
@@ -48,2 +56,2 @@ * | ||
*/ | ||
export declare function Validator(func: (value: any) => boolean): (target: any, propertyKey: string | symbol) => void; | ||
export declare function Validator(func: ValidatorFunction): (target: any, propertyKey: string | symbol) => void; |
@@ -17,1 +17,2 @@ export * from "./ApiError"; | ||
export * from "./UserUtils"; | ||
export * from "./ValidationUtils"; |
{ | ||
"name": "@composer-js/core", | ||
"version": "6.0.0-rc.19", | ||
"version": "6.0.0-rc.20", | ||
"description": "A collection of common utilities and core functionality for composerjs applications.", | ||
@@ -5,0 +5,0 @@ "repository": "https://gitlab.acceleratxr.com/composerjs/composer-core.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229458
75
3823