cowtech-rails 1.1.2.0 → 1.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,56 @@ module Cowtech
|
|
24
24
|
custom_respond_with(rv.to_json)
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
def valid_email?(field)
|
29
|
+
/^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$/i.match(field.to_s) != nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid_phone?(field)
|
33
|
+
/^(((\+|00)\d{1,4}\s?)?(\d{0,4}\s?)?(\d{5,}))?$/i.match(field.to_s) != nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_letter?(field)
|
37
|
+
/^([a-z])$/i.match(field.to_s) != nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid_number?(field)
|
41
|
+
field.to_s.is_valid_float?
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid_date?(field)
|
45
|
+
begin
|
46
|
+
DateTime.strptime(field.to_s, "%d/%m/%Y")
|
47
|
+
true
|
48
|
+
rescue ArgumentError
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def valid_time?(field)
|
54
|
+
begin
|
55
|
+
DateTime.strptime(field.to_s, "%H:%M")
|
56
|
+
true
|
57
|
+
rescue ArgumentError
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid_piva?(field)
|
63
|
+
/^([0-9A-Z]{11,17})$/i.match(field.to_s) != nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def valid_cf?(field)
|
67
|
+
/^([0-9A-Z]{16})$/i.match(field.to_s) != nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def valid_cap?(field)
|
71
|
+
/^([0-9]{5})$/i.match(field.to_s) != nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def valid_password?(field)
|
75
|
+
field.to_s.length >= 8
|
76
|
+
end
|
27
77
|
end
|
28
78
|
end
|
29
79
|
end
|
data/lib/cowtech/version.rb
CHANGED
metadata
CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
- 1
|
8
7
|
- 2
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shogun
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-08 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|