@badrap/valita
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -112,2 +112,22 @@ "use strict"; | ||
} | ||
else if (issue.code === "invalid_length") { | ||
var min = issue.minLength; | ||
var max = issue.maxLength; | ||
message = "expected an array with "; | ||
if (min > 0) { | ||
if (max === min) { | ||
message += "" + min; | ||
} | ||
else if (max < Infinity) { | ||
message += "between " + min + " and " + max; | ||
} | ||
else { | ||
message += "at least " + min; | ||
} | ||
} | ||
else { | ||
message += "at most " + max; | ||
} | ||
message += " item(s)"; | ||
} | ||
else if (issue.code === "custom_error") { | ||
@@ -114,0 +134,0 @@ var error = issue.error; |
@@ -78,2 +78,22 @@ "use strict"; | ||
} | ||
else if (issue.code === "invalid_length") { | ||
const min = issue.minLength; | ||
const max = issue.maxLength; | ||
message = `expected an array with `; | ||
if (min > 0) { | ||
if (max === min) { | ||
message += `${min}`; | ||
} | ||
else if (max < Infinity) { | ||
message += `between ${min} and ${max}`; | ||
} | ||
else { | ||
message += `at least ${min}`; | ||
} | ||
} | ||
else { | ||
message += `at most ${max}`; | ||
} | ||
message += ` item(s)`; | ||
} | ||
else if (issue.code === "custom_error") { | ||
@@ -80,0 +100,0 @@ const error = issue.error; |
{ | ||
"name": "@badrap/valita", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "A validation & parsing library for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/main/index.js", |
@@ -122,2 +122,18 @@ // This is magic that turns object intersections to nicer-looking types. | ||
message = `unrecognized key ${formatLiteral(issue.key)}`; | ||
} else if (issue.code === "invalid_length") { | ||
const min = issue.minLength; | ||
const max = issue.maxLength; | ||
message = `expected an array with `; | ||
if (min > 0) { | ||
if (max === min) { | ||
message += `${min}`; | ||
} else if (max < Infinity) { | ||
message += `between ${min} and ${max}`; | ||
} else { | ||
message += `at least ${min}`; | ||
} | ||
} else { | ||
message += `at most ${max}`; | ||
} | ||
message += ` item(s)`; | ||
} else if (issue.code === "custom_error") { | ||
@@ -124,0 +140,0 @@ const error = issue.error; |
109244
3271