mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 01:13:55 +00:00
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
export const regex = {
|
|
isOnlyNumbers: /^\d+$/,
|
|
isIPAddress: /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/,
|
|
startsWithHttp: /^https?:\/\//,
|
|
startsWithSlash: /^\//,
|
|
isAlphanumeric: /^[a-z0-9]+$/i,
|
|
isAlphanumericWithSpace: /^[a-z0-9_ ]+$/i,
|
|
isASCII: /^[ -~]+$/, // https://catonmat.net/my-favorite-regex
|
|
isASCIIorEmpty: /^$|^[ -~]+$/, // https://catonmat.net/my-favorite-regex
|
|
isNotEmpty: /\S/,
|
|
};
|
|
|
|
export const checkRegex = {
|
|
isOnlyNumbers: (text: string): boolean => regex.isOnlyNumbers.test(text),
|
|
isIPAddress: (text: string): boolean => regex.isIPAddress.test(text),
|
|
startsWithHttp: (text: string): boolean => regex.startsWithHttp.test(text),
|
|
startsWithSlash: (text: string): boolean => regex.startsWithSlash.test(text),
|
|
isAlphanumeric: (text: string): boolean => regex.isAlphanumeric.test(text),
|
|
isAlphanumericWithSpace: (text: string): boolean => regex.isAlphanumericWithSpace.test(text),
|
|
isASCII: (text: string): boolean => regex.isASCII.test(text),
|
|
isASCIIorEmpty: (text: string): boolean => regex.isASCIIorEmpty.test(text),
|
|
isNotEmpty: (text: string): boolean => regex.isNotEmpty.test(text),
|
|
};
|