Comparing version 7.6.1 to 7.6.2
@@ -72,3 +72,3 @@ /* eslint-disable prettier/prettier */ | ||
isDefined.desc = "defined"; | ||
isBoolean.desc = "true or false"; | ||
isBoolean.desc = "boolean"; | ||
isTrue.desc = "true"; | ||
@@ -75,0 +75,0 @@ isFalse.desc = "false"; |
@@ -59,3 +59,4 @@ const BlorkError = require("./errors/BlorkError"); | ||
// Description message joins the descriptions for the checkers. | ||
andChecker.desc = ands.map(checker => checker.desc).join(" and "); | ||
const descs = ands.map(checker => checker.desc); | ||
andChecker.desc = `(${descs.join(" and ")})`; | ||
@@ -83,3 +84,4 @@ // Return it. | ||
// Description message joins the descriptions for the checkers. | ||
orChecker.desc = ors.map(checker => checker.desc).join(" or "); | ||
const descs = ors.map(checker => checker.desc); | ||
orChecker.desc = `(${descs.join(" or ")})`; | ||
@@ -115,3 +117,3 @@ // Return it. | ||
const descs = tupleCheckers.map(c => c.desc).join(", "); | ||
arrayTupleChecker.desc = `${arrayChecker.desc} tuple containing: ${descs}`; | ||
arrayTupleChecker.desc = `${arrayChecker.desc} tuple containing ${descs}`; | ||
@@ -142,3 +144,3 @@ // Return it. | ||
// Description message prepends "plain array containing"; | ||
arrayItemChecker.desc = `${arrayChecker.desc} containing: ${itemChecker.desc}`; | ||
arrayItemChecker.desc = `${arrayChecker.desc} containing ${itemChecker.desc}`; | ||
@@ -179,5 +181,5 @@ // Return it. | ||
? // Key and value check. | ||
`${objectChecker.desc} with ${keyChecker.desc} keys containing: ${valueChecker.desc}` | ||
`${objectChecker.desc} with ${keyChecker.desc} keys containing ${valueChecker.desc}` | ||
: // Just value check. | ||
`${objectChecker.desc} containing: ${valueChecker.desc}`; | ||
`${objectChecker.desc} containing ${valueChecker.desc}`; | ||
@@ -248,3 +250,3 @@ // Return it. | ||
// Description message joins the descriptions for the checkers. | ||
optionalChecker.desc = `${checker.desc} or empty`; | ||
optionalChecker.desc = `(${checker.desc} or empty)`; | ||
@@ -251,0 +253,0 @@ // Return it. |
{ | ||
"name": "blork", | ||
"description": "Blork! Mini runtime type checking in Javascript", | ||
"version": "7.6.1", | ||
"version": "7.6.2", | ||
"license": "0BSD", | ||
@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>", |
@@ -20,3 +20,3 @@ const { check } = require("../lib/exports"); | ||
expect(() => check({}, Promise)).toThrow(TypeError); | ||
expect(() => check(1, Boolean)).toThrow(/Must be true or false/); | ||
expect(() => check(1, Boolean)).toThrow(/Must be boolean/); | ||
expect(() => check("a", Number)).toThrow(/Must be finite number/); | ||
@@ -23,0 +23,0 @@ expect(() => check(null, String)).toThrow(/Must be string/); |
@@ -33,4 +33,4 @@ const BlorkError = require("../lib/errors/BlorkError"); | ||
test("Optional types have correct error message", () => { | ||
expect(() => check(true, "string?")).toThrow(/Must be string or empty/); | ||
expect(() => check("abc", "boolean?")).toThrow(/Must be true or false or empty/); | ||
expect(() => check(true, "string?")).toThrow(/Must be \(string or empty\)/); | ||
expect(() => check("abc", "boolean?")).toThrow(/Must be \(boolean or empty\)/); | ||
}); | ||
@@ -54,3 +54,3 @@ }); | ||
expect(() => check("abc", "!string")).toThrow(/Must be anything except string/); | ||
expect(() => check(true, "!boolean")).toThrow(/Must be anything except true or false/); | ||
expect(() => check(true, "!boolean")).toThrow(/Must be anything except boolean/); | ||
}); | ||
@@ -103,5 +103,5 @@ }); | ||
test("Array types have correct error message", () => { | ||
expect(() => check(true, "str[]")).toThrow(/Must be plain array containing: string/); | ||
expect(() => check([], "str[]+")).toThrow(/Must be non-empty plain array containing: string/); | ||
expect(() => check(["a", "b", ""], "str+[]")).toThrow(/Must be plain array containing: non-empty string/); | ||
expect(() => check(true, "str[]")).toThrow(/Must be plain array containing string/); | ||
expect(() => check([], "str[]+")).toThrow(/Must be non-empty plain array containing string/); | ||
expect(() => check(["a", "b", ""], "str+[]")).toThrow(/Must be plain array containing non-empty string/); | ||
}); | ||
@@ -139,4 +139,4 @@ }); | ||
test("Object types have correct error message", () => { | ||
expect(() => check(true, "{int}")).toThrow(/Must be plain object containing: integer/); | ||
expect(() => check({ "ABC": true }, "{ upper: int }")).toThrow(/Must be plain object with UPPERCASE string keys containing: integer/); | ||
expect(() => check(true, "{int}")).toThrow(/Must be plain object containing integer/); | ||
expect(() => check({ "ABC": true }, "{ upper: int }")).toThrow(/Must be plain object with UPPERCASE string keys containing integer/); | ||
}); | ||
@@ -153,3 +153,3 @@ }); | ||
expect(() => check("a", "number & string")).toThrow(TypeError); | ||
expect(() => check("a", "number & string")).toThrow(/Must be finite number and string/); | ||
expect(() => check("a", "number & string")).toThrow(/Must be \(finite number and string\)/); | ||
}); | ||
@@ -165,3 +165,3 @@ test("OR combined types pass correctly", () => { | ||
expect(() => check(Symbol(), "number|string")).toThrow(TypeError); | ||
expect(() => check(Symbol(), "number|string")).toThrow(/finite number or string/); | ||
expect(() => check(Symbol(), "number|string")).toThrow(/Must be \(finite number or string\)/); | ||
}); | ||
@@ -178,4 +178,4 @@ test("AND and OR combined types combine correctly", () => { | ||
test("AND and OR combined types have correct error message", () => { | ||
expect(() => check(1, "string & string | string")).toThrow(/string and string or string/); | ||
expect(() => check(1, "string | string & string")).toThrow(/string or string and string/); | ||
expect(() => check(1, "string & string | string")).toThrow(/Must be \(string and \(string or string\)\)/); | ||
expect(() => check(1, "string | string & string")).toThrow(/Must be \(\(string or string\) and string\)/); | ||
}); | ||
@@ -200,5 +200,6 @@ }); | ||
expect(() => check(true, "(str | num)")).toThrow(/string or finite number/); | ||
expect(() => check(true, "(str & upper) | (num & int)")).toThrow(/Must be string and UPPERCASE string or finite number and integer/); | ||
expect(() => check([1, "a", true], "(str | num)[]")).toThrow(/Must be plain array containing: string or finite number/); | ||
expect(() => check([1, "a", true], "!(str | num)[]")).toThrow(/Must be plain array containing: anything except string or finite number/); | ||
expect(() => check(true, "(str & upper) | (num & int)")).toThrow(/Must be \(\(string and UPPERCASE string\) or \(finite number and integer\)\)/); | ||
expect(() => check([1, "a", true], "(str | num)[]")).toThrow(/Must be plain array containing \(string or finite number\)/); | ||
expect(() => check([1, "a", true], "!(str | num)[]")).toThrow(/Must be plain array containing anything except \(string or finite number\)/); | ||
expect(() => check([1, "a", true], "(!str | num)[]")).toThrow(/Must be plain array containing \(anything except string or finite number\)/); | ||
}); | ||
@@ -205,0 +206,0 @@ test('Grouping parentheses cannot be nested', () => { |
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
158409
2644