typedconverter
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -68,3 +68,3 @@ import validatorJs from "validator"; | ||
function multibyte(opt?: Opt): (target: any, name: string, index?: any) => void; | ||
function numeric(opt?: Opt): (target: any, name: string, index?: any) => void; | ||
function numeric(opt?: Opt & validatorJs.IsNumericOptions): (target: any, name: string, index?: any) => void; | ||
function port(opt?: Opt): (target: any, name: string, index?: any) => void; | ||
@@ -74,2 +74,3 @@ function postalCode(opt?: Opt & { | ||
}): (target: any, name: string, index?: any) => void; | ||
function slug(opt?: Opt): (target: any, name: string, index?: any) => void; | ||
function surrogatePair(opt?: Opt): (target: any, name: string, index?: any) => void; | ||
@@ -76,0 +77,0 @@ function url(opt?: Opt & validatorJs.IsURLOptions): (target: any, name: string, index?: any) => void; |
@@ -179,2 +179,6 @@ "use strict"; | ||
val.postalCode = postalCode; | ||
function slug(opt) { | ||
return check(x => validator_1.default.isSlug(x), opt && opt.message || "Invalid slug"); | ||
} | ||
val.slug = slug; | ||
function surrogatePair(opt) { | ||
@@ -181,0 +185,0 @@ return check(x => validator_1.default.isSurrogatePair(x), opt && opt.message || "Invalid surrogate pair"); |
@@ -86,4 +86,6 @@ "use strict"; | ||
function visitor(value, ast, opt) { | ||
if (value === undefined || value === null || value.constructor === ast.type || ast.type === Object) | ||
if (value === undefined || value === null) | ||
return { value }; | ||
if (value.constructor === ast.type || ast.type === Object) | ||
return { value: ast.kind === "Array" && opt.guessArrayElement && !Array.isArray(value) ? [value] : value }; | ||
return visitorMap[ast.kind](value, ast, opt); | ||
@@ -90,0 +92,0 @@ } |
{ | ||
"name": "typedconverter", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Convert object into classes match with TypeScript type annotation", | ||
@@ -22,5 +22,5 @@ "main": "lib/index.js", | ||
"@types/validator": "^12.0.1", | ||
"tinspector": "^2.2.9", | ||
"tinspector": "^2.2.10", | ||
"tslib": "^1.10.0", | ||
"validator": "^12.1.0" | ||
"validator": "^12.2.0" | ||
}, | ||
@@ -36,4 +36,4 @@ "devDependencies": { | ||
"ts-jest": "^24.3.0", | ||
"ts-node": "^8.6.1", | ||
"typescript": "^3.7.4" | ||
"ts-node": "^8.6.2", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -40,0 +40,0 @@ "bugs": { |
39156
800
Updatedtinspector@^2.2.10
Updatedvalidator@^12.2.0