-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod1.rb
98 lines (81 loc) · 1.78 KB
/
mod1.rb
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
module Validations
def is_i?(x)#to check feild require numbers only
if(x =~ /[a-z|A-Z|!|@|#|$|%|^|&|*|(|)|_]/)
return false
end
return true#no detected
end
def is_a?(x)#to check feild require charecters only
if(x =~ /[0-9]/)
return false#no found
end
if(x =~ /[!|#|$|%|^|&|*|(|)|;|:|'|\|"|@|}|{]/) #charectars not allowed in username
return false
end
return true#charecters only
end
def username(x)
if(x =~ /[!|#|$|%|^|&|*|(|)|;|:|'|\|"]/) #charectars not allowed in username
return false
end
if((x =~ /^[a-z|A-Z]/) == nil) #/^[a-z|A-Z]/ returns nil if not starting with alphabates only
return false
end
return true
end
def valid_date(x)
a=x.split('/')
t=a[0].to_i
t1=a[1].to_i
t2=a[2].to_i
if ((0 < t) && (t <= 31) && (0 < t1) && (t1 <= 12) && (1950 <= t2) && (t2 <= 2013))
return true
else
return false
end
end
def password(x)
if x.length < 6
return false
else
return true
end
end
def repeate_projectname(x)
if (File.exist?("project.info"))
fin=File.open("project.info","r")
project_info=fin.read.split(" ")
fin.close
len=project_info.length
for i in 0...project_info.length
#puts project_info[i]
case project_info[i]
when "#PROJECT_NAME"
if(project_info[i+1]==x)
#puts "project already exists"
return false
end
end
end #for ends
return true
end#if ends
end#def ends
def repeate_username(x)
if (File.exist?("project.info"))
fin=File.open("project.info","r")
project_info=fin.read.split(" ")
fin.close
len=project_info.length
for i in 0...project_info.length
case project_info[i]
when "#USER_NAME"
if(project_info[i+1]==x)
#puts "project already exists"
return false
end
end
end #for ends
return true
end#if ends
end#def ends
end