phone_number_validator 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +25 -25
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/README.rdoc +59 -59
- data/Rakefile +27 -27
- data/bin/pnv +18 -18
- data/doc/PhoneNumberValidator/Validator.html +230 -230
- data/doc/PhoneNumberValidator.html +160 -160
- data/doc/PhoneNumberValidatorTest.html +235 -235
- data/doc/README_rdoc.html +165 -165
- data/doc/created.rid +6 -6
- data/doc/index.html +159 -159
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +104 -104
- data/lib/phone_number_validator/validator.rb +34 -34
- data/lib/phone_number_validator.rb +18 -18
- data/phone_number_validator.gemspec +32 -32
- data/test/test_phone_number_validator.rb +31 -31
- metadata +2 -2
data/doc/index.html
CHANGED
@@ -1,159 +1,159 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>Phone Number Validator</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
var index_rel_prefix = "./";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="./js/jquery.js"></script>
|
15
|
-
<script src="./js/darkfish.js"></script>
|
16
|
-
|
17
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<body id="top" role="document" class="file">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="./index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
|
38
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
39
|
-
<form action="#" method="get" accept-charset="utf-8">
|
40
|
-
<div id="search-field-wrapper">
|
41
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
42
|
-
aria-autocomplete="list" aria-controls="search-results"
|
43
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
44
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
45
|
-
</div>
|
46
|
-
|
47
|
-
<ul id="search-results" aria-label="Search Results"
|
48
|
-
aria-busy="false" aria-expanded="false"
|
49
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
50
|
-
</form>
|
51
|
-
</div>
|
52
|
-
|
53
|
-
</div>
|
54
|
-
|
55
|
-
<div id="project-metadata">
|
56
|
-
<div id="fileindex-section" class="nav-section">
|
57
|
-
<h3>Pages</h3>
|
58
|
-
|
59
|
-
<ul class="link-list">
|
60
|
-
|
61
|
-
<li><a href="./README_rdoc.html">README</a>
|
62
|
-
|
63
|
-
</ul>
|
64
|
-
</div>
|
65
|
-
|
66
|
-
<div id="classindex-section" class="nav-section">
|
67
|
-
<h3>Class and Module Index</h3>
|
68
|
-
|
69
|
-
<ul class="link-list">
|
70
|
-
|
71
|
-
<li><a href="./PhoneNumberValidator.html">PhoneNumberValidator</a>
|
72
|
-
|
73
|
-
<li><a href="./PhoneNumberValidator/Validator.html">PhoneNumberValidator::Validator</a>
|
74
|
-
|
75
|
-
<li><a href="./PhoneNumberValidatorTest.html">PhoneNumberValidatorTest</a>
|
76
|
-
|
77
|
-
</ul>
|
78
|
-
</div>
|
79
|
-
|
80
|
-
</div>
|
81
|
-
</nav>
|
82
|
-
|
83
|
-
<main role="main">
|
84
|
-
|
85
|
-
|
86
|
-
<h1 id="label-Phone+Number+Validator">Phone Number Validator<span><a href="#label-Phone+Number+Validator">¶</a> <a href="#top">↑</a></span></h1>
|
87
|
-
|
88
|
-
<h2 id="label-About">About<span><a href="#label-About">¶</a> <a href="#top">↑</a></span></h2>
|
89
|
-
|
90
|
-
<p>This app is a US phone number-validating RubyGem.</p>
|
91
|
-
|
92
|
-
<p>It uses a complex regular expression to validate any United States phone
|
93
|
-
number.</p>
|
94
|
-
|
95
|
-
<h3 id="label-Regular+Expression">Regular Expression<span><a href="#label-Regular+Expression">¶</a> <a href="#top">↑</a></span></h3>
|
96
|
-
|
97
|
-
<p>This gem uses the following regular expression:</p>
|
98
|
-
|
99
|
-
<pre class="ruby"><span class="ruby-comment"># US Phone Numbers</span>
|
100
|
-
<span class="ruby-regexp">/^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i</span>
|
101
|
-
<span class="ruby-comment"># Regex Flags: i (ignore case)</span>
|
102
|
-
</pre>
|
103
|
-
|
104
|
-
<h2 id="label-Installing">Installing<span><a href="#label-Installing">¶</a> <a href="#top">↑</a></span></h2>
|
105
|
-
|
106
|
-
<pre>$ gem install phone_number_validator</pre>
|
107
|
-
|
108
|
-
<h3 id="label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies<span><a href="#label-Install+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
109
|
-
|
110
|
-
<pre>$ bundle install</pre>
|
111
|
-
|
112
|
-
<h3 id="label-Updateing+Required+Gems-2FDependencies">Updateing Required Gems/Dependencies<span><a href="#label-Updateing+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
113
|
-
|
114
|
-
<pre>$ bundle update</pre>
|
115
|
-
|
116
|
-
<h2 id="label-Uninstalling">Uninstalling<span><a href="#label-Uninstalling">¶</a> <a href="#top">↑</a></span></h2>
|
117
|
-
|
118
|
-
<pre>$ gem uninstall phone_number_validator</pre>
|
119
|
-
|
120
|
-
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
121
|
-
|
122
|
-
<pre>$ rake test</pre>
|
123
|
-
|
124
|
-
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
125
|
-
|
126
|
-
<h3 id="label-In+command+line">In command line<span><a href="#label-In+command+line">¶</a> <a href="#top">↑</a></span></h3>
|
127
|
-
|
128
|
-
<pre>$ pnv "+1 (949) 355-6244 ext. 198842"</pre>
|
129
|
-
|
130
|
-
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
131
|
-
|
132
|
-
<pre>=> true</pre>
|
133
|
-
|
134
|
-
<h3 id="label-In+Ruby+code">In Ruby code<span><a href="#label-In+Ruby+code">¶</a> <a href="#top">↑</a></span></h3>
|
135
|
-
|
136
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'phone_number_validator'</span>
|
137
|
-
|
138
|
-
<span class="ruby-identifier">check_phone_number</span> = <span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'+1 (949) 355-6244 ext. 198842'</span>)
|
139
|
-
|
140
|
-
<span class="ruby-identifier">print</span> <span class="ruby-identifier">check_phone_number</span>
|
141
|
-
</pre>
|
142
|
-
|
143
|
-
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
144
|
-
|
145
|
-
<pre>=> true</pre>
|
146
|
-
|
147
|
-
<p>Output can be <strong>true</strong> (<em>boolean, valid phone number</em>),
|
148
|
-
<strong>false</strong> (<em>boolean, invalid phone number</em>), or
|
149
|
-
<strong>nil</strong> (<em>symbol, no phone number entered</em>).</p>
|
150
|
-
</main>
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
<footer id="validator-badges" role="contentinfo">
|
155
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
156
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.
|
157
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
158
|
-
</footer>
|
159
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>Phone Number Validator</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" role="document" class="file">
|
23
|
+
<nav role="navigation">
|
24
|
+
<div id="project-navigation">
|
25
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
+
<h2>
|
27
|
+
<a href="./index.html" rel="home">Home</a>
|
28
|
+
</h2>
|
29
|
+
|
30
|
+
<div id="table-of-contents-navigation">
|
31
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
|
38
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
39
|
+
<form action="#" method="get" accept-charset="utf-8">
|
40
|
+
<div id="search-field-wrapper">
|
41
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
42
|
+
aria-autocomplete="list" aria-controls="search-results"
|
43
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
44
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<ul id="search-results" aria-label="Search Results"
|
48
|
+
aria-busy="false" aria-expanded="false"
|
49
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
50
|
+
</form>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<div id="project-metadata">
|
56
|
+
<div id="fileindex-section" class="nav-section">
|
57
|
+
<h3>Pages</h3>
|
58
|
+
|
59
|
+
<ul class="link-list">
|
60
|
+
|
61
|
+
<li><a href="./README_rdoc.html">README</a>
|
62
|
+
|
63
|
+
</ul>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div id="classindex-section" class="nav-section">
|
67
|
+
<h3>Class and Module Index</h3>
|
68
|
+
|
69
|
+
<ul class="link-list">
|
70
|
+
|
71
|
+
<li><a href="./PhoneNumberValidator.html">PhoneNumberValidator</a>
|
72
|
+
|
73
|
+
<li><a href="./PhoneNumberValidator/Validator.html">PhoneNumberValidator::Validator</a>
|
74
|
+
|
75
|
+
<li><a href="./PhoneNumberValidatorTest.html">PhoneNumberValidatorTest</a>
|
76
|
+
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
</div>
|
81
|
+
</nav>
|
82
|
+
|
83
|
+
<main role="main">
|
84
|
+
|
85
|
+
|
86
|
+
<h1 id="label-Phone+Number+Validator">Phone Number Validator<span><a href="#label-Phone+Number+Validator">¶</a> <a href="#top">↑</a></span></h1>
|
87
|
+
|
88
|
+
<h2 id="label-About">About<span><a href="#label-About">¶</a> <a href="#top">↑</a></span></h2>
|
89
|
+
|
90
|
+
<p>This app is a US phone number-validating RubyGem.</p>
|
91
|
+
|
92
|
+
<p>It uses a complex regular expression to validate any United States phone
|
93
|
+
number.</p>
|
94
|
+
|
95
|
+
<h3 id="label-Regular+Expression">Regular Expression<span><a href="#label-Regular+Expression">¶</a> <a href="#top">↑</a></span></h3>
|
96
|
+
|
97
|
+
<p>This gem uses the following regular expression:</p>
|
98
|
+
|
99
|
+
<pre class="ruby"><span class="ruby-comment"># US Phone Numbers</span>
|
100
|
+
<span class="ruby-regexp">/^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i</span>
|
101
|
+
<span class="ruby-comment"># Regex Flags: i (ignore case)</span>
|
102
|
+
</pre>
|
103
|
+
|
104
|
+
<h2 id="label-Installing">Installing<span><a href="#label-Installing">¶</a> <a href="#top">↑</a></span></h2>
|
105
|
+
|
106
|
+
<pre>$ gem install phone_number_validator</pre>
|
107
|
+
|
108
|
+
<h3 id="label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies<span><a href="#label-Install+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
109
|
+
|
110
|
+
<pre>$ bundle install</pre>
|
111
|
+
|
112
|
+
<h3 id="label-Updateing+Required+Gems-2FDependencies">Updateing Required Gems/Dependencies<span><a href="#label-Updateing+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
113
|
+
|
114
|
+
<pre>$ bundle update</pre>
|
115
|
+
|
116
|
+
<h2 id="label-Uninstalling">Uninstalling<span><a href="#label-Uninstalling">¶</a> <a href="#top">↑</a></span></h2>
|
117
|
+
|
118
|
+
<pre>$ gem uninstall phone_number_validator</pre>
|
119
|
+
|
120
|
+
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
121
|
+
|
122
|
+
<pre>$ rake test</pre>
|
123
|
+
|
124
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
125
|
+
|
126
|
+
<h3 id="label-In+command+line">In command line<span><a href="#label-In+command+line">¶</a> <a href="#top">↑</a></span></h3>
|
127
|
+
|
128
|
+
<pre>$ pnv "+1 (949) 355-6244 ext. 198842"</pre>
|
129
|
+
|
130
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
131
|
+
|
132
|
+
<pre>=> true</pre>
|
133
|
+
|
134
|
+
<h3 id="label-In+Ruby+code">In Ruby code<span><a href="#label-In+Ruby+code">¶</a> <a href="#top">↑</a></span></h3>
|
135
|
+
|
136
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'phone_number_validator'</span>
|
137
|
+
|
138
|
+
<span class="ruby-identifier">check_phone_number</span> = <span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'+1 (949) 355-6244 ext. 198842'</span>)
|
139
|
+
|
140
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">check_phone_number</span>
|
141
|
+
</pre>
|
142
|
+
|
143
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
144
|
+
|
145
|
+
<pre>=> true</pre>
|
146
|
+
|
147
|
+
<p>Output can be <strong>true</strong> (<em>boolean, valid phone number</em>),
|
148
|
+
<strong>false</strong> (<em>boolean, invalid phone number</em>), or
|
149
|
+
<strong>nil</strong> (<em>symbol, no phone number entered</em>).</p>
|
150
|
+
</main>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<footer id="validator-badges" role="contentinfo">
|
155
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
156
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.4.
|
157
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
158
|
+
</footer>
|
159
|
+
|
data/doc/js/navigation.js.gz
CHANGED
Binary file
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/js/searcher.js.gz
CHANGED
Binary file
|
data/doc/table_of_contents.html
CHANGED
@@ -1,104 +1,104 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>Table of Contents - Phone Number Validator</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
var index_rel_prefix = "./";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="./js/jquery.js"></script>
|
15
|
-
<script src="./js/darkfish.js"></script>
|
16
|
-
|
17
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<body id="top" class="table-of-contents">
|
23
|
-
<main role="main">
|
24
|
-
<h1 class="class">Table of Contents - Phone Number Validator</h1>
|
25
|
-
|
26
|
-
<h2 id="pages">Pages</h2>
|
27
|
-
<ul>
|
28
|
-
<li class="file">
|
29
|
-
<a href="README_rdoc.html">README</a>
|
30
|
-
|
31
|
-
<ul>
|
32
|
-
<li><a href="README_rdoc.html#label-Phone+Number+Validator">Phone Number Validator</a>
|
33
|
-
<li><a href="README_rdoc.html#label-About">About</a>
|
34
|
-
<li><a href="README_rdoc.html#label-Regular+Expression">Regular Expression</a>
|
35
|
-
<li><a href="README_rdoc.html#label-Installing">Installing</a>
|
36
|
-
<li><a href="README_rdoc.html#label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies</a>
|
37
|
-
<li><a href="README_rdoc.html#label-Updateing+Required+Gems-2FDependencies">Updateing Required Gems/Dependencies</a>
|
38
|
-
<li><a href="README_rdoc.html#label-Uninstalling">Uninstalling</a>
|
39
|
-
<li><a href="README_rdoc.html#label-Testing">Testing</a>
|
40
|
-
<li><a href="README_rdoc.html#label-Usage">Usage</a>
|
41
|
-
<li><a href="README_rdoc.html#label-In+command+line">In command line</a>
|
42
|
-
<li><a href="README_rdoc.html#label-Output">Output</a>
|
43
|
-
<li><a href="README_rdoc.html#label-In+Ruby+code">In Ruby code</a>
|
44
|
-
<li><a href="README_rdoc.html#label-Output">Output</a>
|
45
|
-
</ul>
|
46
|
-
</li>
|
47
|
-
|
48
|
-
</ul>
|
49
|
-
|
50
|
-
<h2 id="classes">Classes and Modules</h2>
|
51
|
-
<ul>
|
52
|
-
<li class="class">
|
53
|
-
<a href="PhoneNumberValidator.html">PhoneNumberValidator</a>
|
54
|
-
</li>
|
55
|
-
<li class="class">
|
56
|
-
<a href="PhoneNumberValidator/Validator.html">PhoneNumberValidator::Validator</a>
|
57
|
-
</li>
|
58
|
-
<li class="class">
|
59
|
-
<a href="PhoneNumberValidatorTest.html">PhoneNumberValidatorTest</a>
|
60
|
-
</li>
|
61
|
-
</ul>
|
62
|
-
|
63
|
-
<h2 id="methods">Methods</h2>
|
64
|
-
<ul>
|
65
|
-
|
66
|
-
<li class="method">
|
67
|
-
<a href="PhoneNumberValidator/Validator.html#method-c-new">::new</a>
|
68
|
-
—
|
69
|
-
<span class="container">PhoneNumberValidator::Validator</span>
|
70
|
-
|
71
|
-
<li class="method">
|
72
|
-
<a href="PhoneNumberValidator.html#method-c-validate">::validate</a>
|
73
|
-
—
|
74
|
-
<span class="container">PhoneNumberValidator</span>
|
75
|
-
|
76
|
-
<li class="method">
|
77
|
-
<a href="PhoneNumberValidatorTest.html#method-i-test_invalid_phone_number">#test_invalid_phone_number</a>
|
78
|
-
—
|
79
|
-
<span class="container">PhoneNumberValidatorTest</span>
|
80
|
-
|
81
|
-
<li class="method">
|
82
|
-
<a href="PhoneNumberValidatorTest.html#method-i-test_no_phone_number">#test_no_phone_number</a>
|
83
|
-
—
|
84
|
-
<span class="container">PhoneNumberValidatorTest</span>
|
85
|
-
|
86
|
-
<li class="method">
|
87
|
-
<a href="PhoneNumberValidatorTest.html#method-i-test_valid_phone_number">#test_valid_phone_number</a>
|
88
|
-
—
|
89
|
-
<span class="container">PhoneNumberValidatorTest</span>
|
90
|
-
|
91
|
-
<li class="method">
|
92
|
-
<a href="PhoneNumberValidator/Validator.html#method-i-validate">#validate</a>
|
93
|
-
—
|
94
|
-
<span class="container">PhoneNumberValidator::Validator</span>
|
95
|
-
</ul>
|
96
|
-
</main>
|
97
|
-
|
98
|
-
|
99
|
-
<footer id="validator-badges" role="contentinfo">
|
100
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
101
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.
|
102
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
103
|
-
</footer>
|
104
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>Table of Contents - Phone Number Validator</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" class="table-of-contents">
|
23
|
+
<main role="main">
|
24
|
+
<h1 class="class">Table of Contents - Phone Number Validator</h1>
|
25
|
+
|
26
|
+
<h2 id="pages">Pages</h2>
|
27
|
+
<ul>
|
28
|
+
<li class="file">
|
29
|
+
<a href="README_rdoc.html">README</a>
|
30
|
+
|
31
|
+
<ul>
|
32
|
+
<li><a href="README_rdoc.html#label-Phone+Number+Validator">Phone Number Validator</a>
|
33
|
+
<li><a href="README_rdoc.html#label-About">About</a>
|
34
|
+
<li><a href="README_rdoc.html#label-Regular+Expression">Regular Expression</a>
|
35
|
+
<li><a href="README_rdoc.html#label-Installing">Installing</a>
|
36
|
+
<li><a href="README_rdoc.html#label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies</a>
|
37
|
+
<li><a href="README_rdoc.html#label-Updateing+Required+Gems-2FDependencies">Updateing Required Gems/Dependencies</a>
|
38
|
+
<li><a href="README_rdoc.html#label-Uninstalling">Uninstalling</a>
|
39
|
+
<li><a href="README_rdoc.html#label-Testing">Testing</a>
|
40
|
+
<li><a href="README_rdoc.html#label-Usage">Usage</a>
|
41
|
+
<li><a href="README_rdoc.html#label-In+command+line">In command line</a>
|
42
|
+
<li><a href="README_rdoc.html#label-Output">Output</a>
|
43
|
+
<li><a href="README_rdoc.html#label-In+Ruby+code">In Ruby code</a>
|
44
|
+
<li><a href="README_rdoc.html#label-Output">Output</a>
|
45
|
+
</ul>
|
46
|
+
</li>
|
47
|
+
|
48
|
+
</ul>
|
49
|
+
|
50
|
+
<h2 id="classes">Classes and Modules</h2>
|
51
|
+
<ul>
|
52
|
+
<li class="class">
|
53
|
+
<a href="PhoneNumberValidator.html">PhoneNumberValidator</a>
|
54
|
+
</li>
|
55
|
+
<li class="class">
|
56
|
+
<a href="PhoneNumberValidator/Validator.html">PhoneNumberValidator::Validator</a>
|
57
|
+
</li>
|
58
|
+
<li class="class">
|
59
|
+
<a href="PhoneNumberValidatorTest.html">PhoneNumberValidatorTest</a>
|
60
|
+
</li>
|
61
|
+
</ul>
|
62
|
+
|
63
|
+
<h2 id="methods">Methods</h2>
|
64
|
+
<ul>
|
65
|
+
|
66
|
+
<li class="method">
|
67
|
+
<a href="PhoneNumberValidator/Validator.html#method-c-new">::new</a>
|
68
|
+
—
|
69
|
+
<span class="container">PhoneNumberValidator::Validator</span>
|
70
|
+
|
71
|
+
<li class="method">
|
72
|
+
<a href="PhoneNumberValidator.html#method-c-validate">::validate</a>
|
73
|
+
—
|
74
|
+
<span class="container">PhoneNumberValidator</span>
|
75
|
+
|
76
|
+
<li class="method">
|
77
|
+
<a href="PhoneNumberValidatorTest.html#method-i-test_invalid_phone_number">#test_invalid_phone_number</a>
|
78
|
+
—
|
79
|
+
<span class="container">PhoneNumberValidatorTest</span>
|
80
|
+
|
81
|
+
<li class="method">
|
82
|
+
<a href="PhoneNumberValidatorTest.html#method-i-test_no_phone_number">#test_no_phone_number</a>
|
83
|
+
—
|
84
|
+
<span class="container">PhoneNumberValidatorTest</span>
|
85
|
+
|
86
|
+
<li class="method">
|
87
|
+
<a href="PhoneNumberValidatorTest.html#method-i-test_valid_phone_number">#test_valid_phone_number</a>
|
88
|
+
—
|
89
|
+
<span class="container">PhoneNumberValidatorTest</span>
|
90
|
+
|
91
|
+
<li class="method">
|
92
|
+
<a href="PhoneNumberValidator/Validator.html#method-i-validate">#validate</a>
|
93
|
+
—
|
94
|
+
<span class="container">PhoneNumberValidator::Validator</span>
|
95
|
+
</ul>
|
96
|
+
</main>
|
97
|
+
|
98
|
+
|
99
|
+
<footer id="validator-badges" role="contentinfo">
|
100
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
101
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.4.
|
102
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
103
|
+
</footer>
|
104
|
+
|
@@ -1,34 +1,34 @@
|
|
1
|
-
##
|
2
|
-
# This class does all of the matching and checking work for the validation of the phone number.
|
3
|
-
class PhoneNumberValidator::Validator
|
4
|
-
|
5
|
-
##
|
6
|
-
# The regex pattern for validating US phone numbers
|
7
|
-
#
|
8
|
-
# Regular Expression tested using {regexr.com}[https://regexr.com/]
|
9
|
-
#
|
10
|
-
# The regular expression used can be found in <em>README.rdoc</em> on the documentation's home page
|
11
|
-
PHONE_NUMBER_REGEX = Regexp.new('^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$', Regexp::IGNORECASE)
|
12
|
-
|
13
|
-
##
|
14
|
-
# initializes the <b>@phone_number</b> instance variable
|
15
|
-
def initialize(phone_number = '+1 (949) 355-6244 ext. 198842')
|
16
|
-
@phone_number = phone_number
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Checks to see if the phone number the user entered is valid
|
21
|
-
# by testing regex the pattern with the phone number
|
22
|
-
#
|
23
|
-
# <b>Return Type:</b>
|
24
|
-
# boolean or symbol
|
25
|
-
def validate
|
26
|
-
if (@phone_number.match(PHONE_NUMBER_REGEX))
|
27
|
-
return true
|
28
|
-
elsif (@phone_number == '' || @phone_number == nil)
|
29
|
-
return :nil
|
30
|
-
else
|
31
|
-
return false
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
##
|
2
|
+
# This class does all of the matching and checking work for the validation of the phone number.
|
3
|
+
class PhoneNumberValidator::Validator
|
4
|
+
|
5
|
+
##
|
6
|
+
# The regex pattern for validating US phone numbers
|
7
|
+
#
|
8
|
+
# Regular Expression tested using {regexr.com}[https://regexr.com/]
|
9
|
+
#
|
10
|
+
# The regular expression used can be found in <em>README.rdoc</em> on the documentation's home page
|
11
|
+
PHONE_NUMBER_REGEX = Regexp.new('^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$', Regexp::IGNORECASE)
|
12
|
+
|
13
|
+
##
|
14
|
+
# initializes the <b>@phone_number</b> instance variable
|
15
|
+
def initialize(phone_number = '+1 (949) 355-6244 ext. 198842')
|
16
|
+
@phone_number = phone_number
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Checks to see if the phone number the user entered is valid
|
21
|
+
# by testing regex the pattern with the phone number
|
22
|
+
#
|
23
|
+
# <b>Return Type:</b>
|
24
|
+
# boolean or symbol
|
25
|
+
def validate
|
26
|
+
if (@phone_number.match(PHONE_NUMBER_REGEX))
|
27
|
+
return true
|
28
|
+
elsif (@phone_number == '' || @phone_number == nil)
|
29
|
+
return :nil
|
30
|
+
else
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
##
|
2
|
-
# This class is the master/parent class to all of the validation functionality
|
3
|
-
class PhoneNumberValidator
|
4
|
-
class << self
|
5
|
-
|
6
|
-
##
|
7
|
-
# Validates any United States phone number!
|
8
|
-
#
|
9
|
-
# <b>Arguments:</b>
|
10
|
-
# phone_number: (String)
|
11
|
-
def validate(phone_number)
|
12
|
-
validator = Validator.new(phone_number)
|
13
|
-
validator.validate
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'phone_number_validator/validator'
|
1
|
+
##
|
2
|
+
# This class is the master/parent class to all of the validation functionality
|
3
|
+
class PhoneNumberValidator
|
4
|
+
class << self
|
5
|
+
|
6
|
+
##
|
7
|
+
# Validates any United States phone number!
|
8
|
+
#
|
9
|
+
# <b>Arguments:</b>
|
10
|
+
# phone_number: (String)
|
11
|
+
def validate(phone_number)
|
12
|
+
validator = Validator.new(phone_number)
|
13
|
+
validator.validate
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'phone_number_validator/validator'
|