diff --git a/validators/array.test.ts b/validators/array.test.ts index e084bc7..a43ad49 100644 --- a/validators/array.test.ts +++ b/validators/array.test.ts @@ -25,11 +25,11 @@ Deno.test("isArray (no match)", async () => { true, "", "foo", - new String(), - new String("bar"), + String(), + String("bar"), () => {}, function named() {}, - new Object(), + {}, Symbol(), ]; for (const value of values) { diff --git a/validators/boolean.test.ts b/validators/boolean.test.ts index 3b61aab..0ba8839 100644 --- a/validators/boolean.test.ts +++ b/validators/boolean.test.ts @@ -23,11 +23,11 @@ Deno.test("isBoolean (no match)", async () => { 1, "", "foo", - new String(), - new String("bar"), + String(), + String("bar"), () => {}, function named() {}, - new Object(), + {}, Symbol(), ]; for (const value of values) { diff --git a/validators/empty.test.ts b/validators/empty.test.ts index f39f6bf..edfccf5 100644 --- a/validators/empty.test.ts +++ b/validators/empty.test.ts @@ -27,7 +27,7 @@ Deno.test("isRequired (match)", async () => { }); Deno.test("isRequired (no match)", async () => { - const values = [ + const values: (undefined|null)[] = [ undefined, null, ]; @@ -59,7 +59,7 @@ Deno.test("isDefined (match)", async () => { }); Deno.test("isDefined (no match)", async () => { - const values = [ + const values: undefined[] = [ undefined, ]; for (const value of values) { diff --git a/validators/empty.ts b/validators/empty.ts index 86da8fa..318361a 100644 --- a/validators/empty.ts +++ b/validators/empty.ts @@ -66,6 +66,7 @@ export function isNotEmpty(): Validator { } return {}; } + // noinspection LoopStatementThatDoesntLoopJS for (const key in value) { return; } diff --git a/validators/number.test.ts b/validators/number.test.ts index 5053ca6..c28e460 100644 --- a/validators/number.test.ts +++ b/validators/number.test.ts @@ -30,7 +30,7 @@ Deno.test("isNumber (no match)", async () => { false, () => {}, function named() {}, - new Object(), + {}, Symbol(), ]; for (const value of values) { @@ -66,7 +66,7 @@ Deno.test("isInteger (no match)", async () => { false, () => {}, function named() {}, - new Object(), + {}, Symbol(), 0.1, ]; diff --git a/validators/string.test.ts b/validators/string.test.ts index 2584087..1fe4131 100644 --- a/validators/string.test.ts +++ b/validators/string.test.ts @@ -11,8 +11,8 @@ Deno.test("isString (match)", async () => { null, "", "foo", - new String(), - new String("bar"), + String(), + String("bar"), ]; for (const value of values) { assertEquals(await validate(value, isString()), [], String(value)); @@ -27,7 +27,7 @@ Deno.test("isString (no match)", async () => { false, () => {}, function named() {}, - new Object(), + {}, Symbol(), ]; for (const value of values) { diff --git a/validators/string.ts b/validators/string.ts index 4357ac4..2e8cfdd 100644 --- a/validators/string.ts +++ b/validators/string.ts @@ -31,7 +31,7 @@ export function isUrl( allowDomain = true, allowBasicAuth = false, allowPort = true, - allowRecourcePath = true, + allowResourcePath = true, }: { protocols?: string[] | null; allowDataUrl?: boolean; @@ -41,7 +41,7 @@ export function isUrl( allowDomain?: boolean; allowBasicAuth?: boolean; allowPort?: boolean; - allowRecourcePath?: boolean; + allowResourcePath?: boolean; } = {}, ): Validator { return { @@ -95,7 +95,7 @@ export function isUrl( // port number (optional) regex += "(?::\\d{2,5})?"; } - if (allowRecourcePath) { + if (allowResourcePath) { // resource path (optional) regex += "(?:[/?#]\\S*)?"; } @@ -106,7 +106,7 @@ export function isUrl( } if (allowDataUrl) { const regex = - /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i; + /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+=[a-z\-]+)?)?(;base64)?,[a-z0-9!$&',()*+;=\-._~:@\/?%\s]*\s*$/i; if (value.match(regex)) { return; } diff --git a/validators/symbol.test.ts b/validators/symbol.test.ts index af19dd0..54dd3b0 100644 --- a/validators/symbol.test.ts +++ b/validators/symbol.test.ts @@ -24,11 +24,11 @@ Deno.test("isSymbol (no match)", async () => { false, "", "foo", - new String(), - new String("bar"), + String(), + String("bar"), () => {}, function named() {}, - new Object(), + {}, ]; for (const value of values) { assertNotEquals(await validate(value, isSymbol()), [], String(value));