-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatterns.js
24 lines (23 loc) · 1.66 KB
/
patterns.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @copyright 2023 Chris Zuber <[email protected]>
*/
// Inefficient regular expression
// export const TEXT = /^(\w+ ?)+$/;
export const NAME = /^[A-Za-z]{3,30}$/;
export const PASSWORD = /^(?=^.{8,35}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/;
export const EMAIL = /^.+@.+\.+[\w]+$/;
export const URL = /^(https?:\/\/)?[\S]+\.[\S]+$/;
export const TEL = /^\d{3}[-]\d{3}[-]\d{4}$/;
export const NUMBER = /^\d+(\.\d+)?$/;
export const COLOR = /^#?(([0-9A-Fa-f]{3})|([0-9A-Fa-f]{6})|([0-9A-Fa-f]{4})|([0-9A-Fa-f]{8}))$/;
export const DATE = /^(?:19|20)(?:(?:[13579][26]|[02468][048])-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))|(?:[0-9]{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:29|30))|(?:(?:0[13578]|1[02])-31)))$/;
export const TIME = /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/;
export const DATETIME = /^([0-2][0-9]{3})-([0-1][0-9])-([0-3][0-9])T([0-5][0-9]):([0-5][0-9]):([0-5][0-9])(Z|([-+]([0-1][0-9]):00))$/;
export const WEEK = /^\d{4}-W\d{2}$/;
export const CREDIT = /^\d{13,16}$/;
export const HTML_COMMENT = /^<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->$/;
export const MD5 = /^[0-9a-fA-F]{32}$/;
export const IPV4 = /((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$/;
export const IPV6 = /((^|:)([0-9a-fA-F]{0,4})){1,8}$/;
export const GPS = /^-?\d{1,3}\.\d+$/;
export const ISBN = /^(?:(?=.{17}$)97[89][ -](?:[0-9]+[ -]){2}[0-9]+[ -][0-9]|97[89][0-9]{10}|(?=.{13}$)(?:[0-9]+[ -]){2}[0-9]+[ -][0-9Xx]|[0-9]{9}[0-9Xx])$/;