extensible-validator
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -15,4 +15,2 @@ "use strict"; | ||
this.typeTest = function (value) { | ||
console.log({ value }); | ||
console.log(this._parseFormat); | ||
return (value === '' || | ||
@@ -19,0 +17,0 @@ value == null || |
@@ -0,1 +1,2 @@ | ||
export * from './ArraySchema'; | ||
export * from './DateSchema'; | ||
@@ -2,0 +3,0 @@ export * from './NumberSchema'; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./ArraySchema")); | ||
__export(require("./DateSchema")); | ||
@@ -8,0 +9,0 @@ __export(require("./NumberSchema")); |
@@ -19,5 +19,5 @@ import { Schema, ValidationResult } from './Schema'; | ||
[key: string]: any; | ||
}, _context?: ValidationContext): ValidationResult; | ||
}, context?: ValidationContext): ValidationResult; | ||
cast(value: any): any; | ||
} | ||
export declare const object: ObjectSchema<{}>; |
@@ -25,16 +25,9 @@ "use strict"; | ||
} | ||
_validateKeys(values, _context) { | ||
const results = []; | ||
const context = _context | ||
? Object.assign({}, _context) | ||
: { model: values, path: null }; | ||
_validateKeys(values, context = { model: values, path: null }) { | ||
const basePath = context.path ? context.path + '.' : ''; | ||
if (values == null) | ||
return []; | ||
for (const key in this.keyValidation) { | ||
context.path = basePath + key; | ||
const result = this.keyValidation[key].validate(values[key], context); | ||
results.push(...result); | ||
} | ||
return results; | ||
return _.flatMap(this.keyValidation, (schema, key) => { | ||
return schema.validate(values[key], Object.assign({}, context, { path: basePath + key })); | ||
}); | ||
} | ||
@@ -45,7 +38,5 @@ cast(value) { | ||
} | ||
const result = {}; | ||
for (const k in this.keyValidation) { | ||
result[k] = this.keyValidation[k].cast(value[k]); | ||
} | ||
return result; | ||
return _.mapValues(this.keyValidation, (schema, key) => { | ||
return schema.cast(value[key]); | ||
}); | ||
} | ||
@@ -52,0 +43,0 @@ } |
{ | ||
"name": "extensible-validator", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Typescript-friendly and extensible object and value validation", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
35137
30
616