-
Notifications
You must be signed in to change notification settings - Fork 16
/
validator.js.javascript.txt
53 lines (43 loc) · 3.2 KB
/
validator.js.javascript.txt
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
53
VALIDATOR.JS
VALIDATOR ==> #Can be Node package or client-side script (3.16.1)
#This only works on STR. All other VAL will be applied VALIDATOR.toString(VAL)
VALIDATOR.isAlpha[numeric]|
Numeric(STR) #
VALIDATOR.isInt|Float(STR) #
VALIDATOR.isDate(STR) #
VALIDATOR.isEmail(STR) #
VALIDATOR.isURL(STR[, OBJ]) #
#OBJ:
# - protocols (def: [ "http", "https", "ftp" ])
# - require_tld BOOL (def: true)
# - require_protocol BOOL (def: false)
# - allow_underscores BOOL (def: false)
VALIDATOR.isIP[v4|6](STR) #
VALIDATOR.isUUID(STR) #
VALIDATOR.isCreditCard(STR) #
VALIDATR.isISBN(STR[,VERSION])#
VALIDATOR.isJSON(STR) #
VALIDATOR.isBase64(STR) #
VALIDATOR.isHexadecimal(STR) #
VALIDATOR.isHexColor(STR) #
VALIDTR.isLower|Uppercase(STR)#
VALIDATOR.isMultibyte(STR) #
VALIDATOR.isAscii(STR) #
VALIDATR.isFull|HalfWidth(STR)#HalfWidth is the normal one, FullWidth are ones that takes 2 chars space.
#True if contains any such chars.
VALIDATOR.isVariableWidth(STR)#True if contains some fullwidth and some halfwidth
VALIDATOR.toString(VAL) #Like VAL.toString(), except null|undefined|NaN -> ""
VALIDATOR.toDate(STR) #Converts to DATE (DATE_STR, NUM_STR), null otherwise.
VALIDATOR.toFloat(STR) #Converts to FLOAT, NaN otherwise.
VALIDATOR.toInt(STR[,RADIX]) #Converts to INT, NaN otherwise.
VALIDATR.toBoolean(STR[,BOOL])#Converts to BOOL:
# - if false (def): true if not "0", "false" or ""
# - if true: true if "1" or "true"
VALIDATR.[l|r]trim(STR[,STR2])#Trim any chars (can use regexp) in STR2 (def: "\s") from the ends.
#If no STR2, prefer STR.trim() to VALIDATOR.trim()
VALIDATOR.escape(STR) #HTML-escape & " ' < >
VALIDATOR.stripLow(STR[,BOOL])#Removes control chars except (if true (def: false)) \n and \r
VALIDATOR.extend
(FUNC_STR, FUNC(...)) #Adds VALIDATOR.FUNC(...). Input will be VALIDATOR.toString() automatically.