Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 7x 5x 5x 3x 4x 16x 5x 3x 2x 2x | import { parse as uuidParse } from "uuid";
import { integer, long, float } from "@the-neon/core";
export class Valid {
public static uuid(argValue: string): boolean {
if (argValue) {
try {
uuidParse(argValue);
} catch {
return false;
}
}
return true;
}
public static notEmpty(argValue: string): boolean {
return !(
// null
(
typeof argValue === "undefined" ||
argValue === null ||
// string
(typeof argValue === "string" && argValue.toString().length === 0) ||
// Array
(argValue.hasOwnProperty?.("length") && argValue.length === 0) ||
// Object
(typeof argValue === "object" && Object.keys(argValue).length === 0)
)
);
}
public static email(email: string): boolean {
// do not test if no email is provided (use notEmpty for required fields)
if (
(typeof email === "string" && email.length === 0) ||
typeof email === "undefined" ||
email === null
) {
return true;
}
const re =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
public static greaterThanZero(
argValue: string | number | integer | long | float
): boolean {
return +argValue > 0;
}
}
|