forked from sharpobject/sgre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.lua
32 lines (29 loc) · 902 Bytes
/
validate.lua
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
local type = type
function check_username(s)
if type(s) ~= "string" then
return false, "Username must be a string"
elseif s:len() > 12 or s:len() < 3 then
return false, "Username must be 3-12 characters"
elseif s:match("[a-zA-Z0-9]+"):len() ~= s:len() then
return false, "Username can only contain letters and numbers"
end
return true
end
function check_email(s)
if type(s) ~= "string" then
return false, "Email must be a string"
elseif s:len() > 100 or s:len() < 3 then
return false, "Email must be 3-100 characters"
elseif not s:match(".+@.+") then
return false, "Email must be stuff, then @, then more stuff"
end
return true
end
function check_password(s)
if type(s) ~= "string" then
return false, "Password must be a string"
elseif s:len() < 6 or s:len() > 100 then
return false, "Password must be 6-100 characters"
end
return true
end