UNPKG
qeasy
Version:
latest (1.0.5)
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
Query Easy: Simple SQL helper like Mongoose for MySQL/MariaDB
qeasy
/
validator
/
validateIdentifier.js
7 lines
(6 loc)
•
195 B
JavaScript
View Raw
1
2
3
4
5
6
7
exports
.
validateIdentifier
=
(
name,
type
=
"identifier"
) =>
{
const
nameRegex =
/^[a-zA-Z0-9_]+$/
;
if
(!nameRegex.
test
(name)) {
throw
new
Error
(
`Invalid
${
type
}
: "
${name}
"`
); } }