FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
roadmap/app/javascript/src/utils/isValidInputType.js at api-patch · DMPRoadmap/roadmap · GitHub
DMPRoadmap
roadmap
Repository navigation
Code
Issues
300
(300)
Pull requests
49
(49)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
roadmap
/
app
/
javascript
/
src
/
utils
/
isValidInputType.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (74 loc) · 2.2 KB
Breadcrumbs
roadmap
/
app
/
javascript
/
src
/
utils
/
isValidInputType.js
Copy path
File metadata and controls
80 lines (74 loc) · 2.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import
{
isObject
,
isString
,
isNumber
}
from
'./isType'
;
import
getConstant
from
'./constants'
;
/*
Validates whether or not the value passed matches to a valid email
@param
value String to search for a match
@return
true or false
*/
export
const
isValidEmail
=
(
value
)
=>
{
if
(
isString
(
value
)
)
{
return
/
[
^
@
\s
]
+
@
(?:
[
-
a
-
z
A
-
Z
0
-
9
]
+
\.
)
+
[
a
-
z
A
-
Z
]
{
2
,
}
$
/
.
test
(
value
)
;
}
return
false
;
}
;
/*
Validates whether or not the value passed matches to a valid url
@param
value String to search for a match
@return
true or false
*/
export
const
isValidUrl
=
(
value
)
=>
{
if
(
isString
(
value
)
)
{
return
/
h
t
t
p
s
?
:
\/
\/
[
-
a
-
z
A
-
Z
0
-
9
@
:
%
_
+
.
~
#
?
&
=
]
{
2
,
256
}
\.
[
a
-
z
]
{
2
,
4
}
\b
(
\/
[
-
a
-
z
A
-
Z
0
-
9
@
:
%
_
+
.
~
#
?
&
=
]
*
)
?
/
.
test
(
value
)
;
}
return
false
;
}
;
/*
Validates whether or not the value passed is a valid number.
@param
value Number to validate
*/
export
const
isValidNumber
=
(
value
)
=>
{
if
(
isString
(
value
)
&&
value
.
trim
(
)
.
length
>
0
)
{
// Only if is non-empty string value we try to convert to Number
// since Number([]), Number(new Date()), Number(null) are converted to zero
return
!
Number
.
isNaN
(
Number
(
value
)
)
;
}
return
isNumber
(
value
)
;
}
;
/*
Validates whether or not the value passed falls between the min and max length
string specified for a password.
@param
value String to verify its length
@return
true or false
*/
export
const
isValidPassword
=
(
value
)
=>
{
const
minLength
=
getConstant
(
'PASSWORD_MIN_LENGTH'
)
||
8
;
const
maxLength
=
getConstant
(
'PASSWORD_MAX_LENGTH'
)
||
128
;
if
(
isString
(
value
)
)
{
const
trimmed
=
value
.
trim
(
)
;
return
trimmed
.
length
>=
minLength
&&
trimmed
.
length
<=
maxLength
;
}
return
false
;
}
;
/*
Validates whether or not the value passed is a non-empty String type.
@param
value String to verify its length
@return
true or false
*/
export
const
isValidText
=
(
value
)
=>
{
if
(
isString
(
value
)
)
{
return
value
.
trim
(
)
.
length
>
0
;
}
return
false
;
}
;
export
const
isValidCheckbox
=
(
el
)
=>
{
if
(
isObject
(
el
)
)
{
return
el
.
is
(
':checked'
)
;
}
return
false
;
}
;
export
const
isValidMultiCheckbox
=
(
el
)
=>
{
if
(
isObject
(
el
)
&&
isObject
(
el
.
closest
(
'fieldset'
)
)
)
{
return
el
.
closest
(
'fieldset'
)
.
find
(
'input:checked'
)
.
length
>
0
;
}
return
false
;
}
;
Back
|
FazBrowse Home
|
New Git URL