simplified stuff (thx WebStorm)

This commit is contained in:
Sebastian Seedorf
2020-12-05 23:00:08 +01:00
parent adf8c400bc
commit 87e69e29c6
8 changed files with 21 additions and 20 deletions

View File

@@ -25,11 +25,11 @@ Deno.test("isArray (no match)", async () => {
true, true,
"", "",
"foo", "foo",
new String(), String(),
new String("bar"), String("bar"),
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
Symbol(), Symbol(),
]; ];
for (const value of values) { for (const value of values) {

View File

@@ -23,11 +23,11 @@ Deno.test("isBoolean (no match)", async () => {
1, 1,
"", "",
"foo", "foo",
new String(), String(),
new String("bar"), String("bar"),
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
Symbol(), Symbol(),
]; ];
for (const value of values) { for (const value of values) {

View File

@@ -27,7 +27,7 @@ Deno.test("isRequired (match)", async () => {
}); });
Deno.test("isRequired (no match)", async () => { Deno.test("isRequired (no match)", async () => {
const values = [ const values: (undefined|null)[] = [
undefined, undefined,
null, null,
]; ];
@@ -59,7 +59,7 @@ Deno.test("isDefined (match)", async () => {
}); });
Deno.test("isDefined (no match)", async () => { Deno.test("isDefined (no match)", async () => {
const values = [ const values: undefined[] = [
undefined, undefined,
]; ];
for (const value of values) { for (const value of values) {

View File

@@ -66,6 +66,7 @@ export function isNotEmpty(): Validator {
} }
return {}; return {};
} }
// noinspection LoopStatementThatDoesntLoopJS
for (const key in value) { for (const key in value) {
return; return;
} }

View File

@@ -30,7 +30,7 @@ Deno.test("isNumber (no match)", async () => {
false, false,
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
Symbol(), Symbol(),
]; ];
for (const value of values) { for (const value of values) {
@@ -66,7 +66,7 @@ Deno.test("isInteger (no match)", async () => {
false, false,
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
Symbol(), Symbol(),
0.1, 0.1,
]; ];

View File

@@ -11,8 +11,8 @@ Deno.test("isString (match)", async () => {
null, null,
"", "",
"foo", "foo",
new String(), String(),
new String("bar"), String("bar"),
]; ];
for (const value of values) { for (const value of values) {
assertEquals(await validate(value, isString()), [], String(value)); assertEquals(await validate(value, isString()), [], String(value));
@@ -27,7 +27,7 @@ Deno.test("isString (no match)", async () => {
false, false,
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
Symbol(), Symbol(),
]; ];
for (const value of values) { for (const value of values) {

View File

@@ -31,7 +31,7 @@ export function isUrl(
allowDomain = true, allowDomain = true,
allowBasicAuth = false, allowBasicAuth = false,
allowPort = true, allowPort = true,
allowRecourcePath = true, allowResourcePath = true,
}: { }: {
protocols?: string[] | null; protocols?: string[] | null;
allowDataUrl?: boolean; allowDataUrl?: boolean;
@@ -41,7 +41,7 @@ export function isUrl(
allowDomain?: boolean; allowDomain?: boolean;
allowBasicAuth?: boolean; allowBasicAuth?: boolean;
allowPort?: boolean; allowPort?: boolean;
allowRecourcePath?: boolean; allowResourcePath?: boolean;
} = {}, } = {},
): Validator { ): Validator {
return { return {
@@ -95,7 +95,7 @@ export function isUrl(
// port number (optional) // port number (optional)
regex += "(?::\\d{2,5})?"; regex += "(?::\\d{2,5})?";
} }
if (allowRecourcePath) { if (allowResourcePath) {
// resource path (optional) // resource path (optional)
regex += "(?:[/?#]\\S*)?"; regex += "(?:[/?#]\\S*)?";
} }
@@ -106,7 +106,7 @@ export function isUrl(
} }
if (allowDataUrl) { if (allowDataUrl) {
const regex = 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)) { if (value.match(regex)) {
return; return;
} }

View File

@@ -24,11 +24,11 @@ Deno.test("isSymbol (no match)", async () => {
false, false,
"", "",
"foo", "foo",
new String(), String(),
new String("bar"), String("bar"),
() => {}, () => {},
function named() {}, function named() {},
new Object(), {},
]; ];
for (const value of values) { for (const value of values) {
assertNotEquals(await validate(value, isSymbol()), [], String(value)); assertNotEquals(await validate(value, isSymbol()), [], String(value));