simplified stuff (thx WebStorm)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -66,6 +66,7 @@ export function isNotEmpty(): Validator {
|
||||
}
|
||||
return {};
|
||||
}
|
||||
// noinspection LoopStatementThatDoesntLoopJS
|
||||
for (const key in value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user