typedconverter
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -48,3 +48,3 @@ "use strict"; | ||
if (isEmpty(result) && !isOptional(i) && !isPartial(i)) | ||
return visitor_1.Result.error(i.path, `Required`); | ||
return visitor_1.Result.error(i.value, i.path, `Required`); | ||
else | ||
@@ -74,5 +74,5 @@ return result; | ||
} | ||
return messages.length > 0 ? visitor_1.Result.error(i.path, messages) : result; | ||
return messages.length > 0 ? visitor_1.Result.error(i.value, i.path, messages) : result; | ||
} | ||
} | ||
exports.validatorVisitor = validatorVisitor; |
@@ -26,5 +26,5 @@ import { VisitorExtension } from "./invocation"; | ||
function create(value: any): Result; | ||
function error(path: string, message: string | string[]): Result; | ||
function error(value: any, path: string, message: string | string[]): Result; | ||
} | ||
declare function pipeline(value: any, ast: SuperNode, opt: VisitorOption): Result; | ||
export { pipeline, ResultMessages, Result, ParentInfo }; |
@@ -13,4 +13,4 @@ "use strict"; | ||
Result.create = create; | ||
function error(path, message) { | ||
return { value: undefined, issues: [{ path, messages: Array.isArray(message) ? message : [message] }] }; | ||
function error(value, path, message) { | ||
return { value, issues: [{ path, messages: Array.isArray(message) ? message : [message] }] }; | ||
} | ||
@@ -40,3 +40,3 @@ Result.error = error; | ||
if (result === undefined) | ||
return Result.error(opt.path, unableToConvert(value, ast.type.name)); | ||
return Result.error(value, opt.path, unableToConvert(value, ast.type.name)); | ||
else | ||
@@ -48,3 +48,3 @@ return Result.create(result); | ||
if (!Array.isArray(newValues)) | ||
return Result.error(opt.path, unableToConvert(value, `Array<${ast.type.name}>`)); | ||
return Result.error(value, opt.path, unableToConvert(value, `Array<${ast.type.name}>`)); | ||
const result = []; | ||
@@ -68,3 +68,3 @@ const errors = []; | ||
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") | ||
return Result.error(opt.path, unableToConvert(value, ast.type.name)); | ||
return Result.error(value, opt.path, unableToConvert(value, ast.type.name)); | ||
const instance = Object.create(ast.type.prototype); | ||
@@ -71,0 +71,0 @@ const meta = tinspector_1.default(ast.type); |
{ | ||
"name": "typedconverter", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Convert object into classes match with TypeScript type annotation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
39753