-
Notifications
You must be signed in to change notification settings - Fork 0
/
30_specs.html
124 lines (121 loc) · 16.3 KB
/
30_specs.html
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Specs and checks</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script><link rel="stylesheet" type="text/css" href="css/randomseed.css" /></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Phone-number</span> <span class="project-version">8.13.6-3</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="10_introduction.html"><div class="inner"><span>Introduction</span></div></a></li><li class="depth-1 current"><a href="30_specs.html"><div class="inner"><span>Specs and checks</span></div></a></li><li class="depth-1 "><a href="40_development.html"><div class="inner"><span>Development</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><a href="phone-number.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>phone-number</span></div></a></li><li class="depth-2 branch"><a href="phone-number.calling-code.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>calling-code</span></div></a></li><li class="depth-2 branch"><a href="phone-number.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 branch"><a href="phone-number.cost.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>cost</span></div></a></li><li class="depth-2 branch"><a href="phone-number.country-code.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>country-code</span></div></a></li><li class="depth-2 branch"><a href="phone-number.db.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>db</span></div></a></li><li class="depth-2 branch"><a href="phone-number.format.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>format</span></div></a></li><li class="depth-2 branch"><a href="phone-number.leniency.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>leniency</span></div></a></li><li class="depth-2 branch"><a href="phone-number.locale.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>locale</span></div></a></li><li class="depth-2 branch"><a href="phone-number.match.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>match</span></div></a></li><li class="depth-2 branch"><a href="phone-number.net-code.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>net-code</span></div></a></li><li class="depth-2 branch"><a href="phone-number.region.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>region</span></div></a></li><li class="depth-2 branch"><a href="phone-number.type.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>type</span></div></a></li><li class="depth-2 branch"><a href="phone-number.tz-format.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tz-format</span></div></a></li><li class="depth-2"><a href="phone-number.util.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>util</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#specs-and-checks" id="specs-and-checks"></a>Specs and checks</h1>
<h2><a href="#predicates" id="predicates"></a>Predicates</h2>
<p>The phone-number provides many predicate functions that can be used to check for certain properties of phone numbers. These include:</p>
<table>
<thead>
<tr><th> Function Name </th><th> Description </th></tr>
</thead>
<tbody>
<tr><td> <a href="phone-number.core.html#var-valid-input.3F"><code>core/valid-input?</code></a> </td><td> Checks if a value can possibly be used as a phone number </td></tr>
<tr><td> <a href="phone-number.core.html#var-valid.3F"><code>core/valid?</code></a> </td><td> Checks if a phone numer is valid </td></tr>
<tr><td> <a href="phone-number.core.html#var-invalid.3F"><code>core/invalid?</code></a> </td><td> Checks if a phone numer is invalid </td></tr>
<tr><td> <a href="phone-number.core.html#var-possible.3F"><code>core/possible?</code></a> </td><td> Checks if a phone numer is a possible number </td></tr>
<tr><td> <a href="phone-number.core.html#var-impossible.3F"><code>core/impossible?</code></a> </td><td> Checks if a phone numer is an impossible number </td></tr>
<tr><td> <a href="phone-number.core.html#var-native.3F"><code>core/native?</code></a> </td><td> Checks if a phone numer is in a native format (<code>PhoneNumber</code>) </td></tr>
<tr><td> <a href="phone-number.core.html#var-has-raw-input.3F"><code>core/has-raw-input?</code></a> </td><td> Checks if a phone numer contains the retained raw input </td></tr>
<tr><td> <a href="phone-number.core.html#var-geographical.3F"><code>core/geographical?</code></a> </td><td> Checks if a phone numer identifies a line with some geographical location </td></tr>
<tr><td> <a href="phone-number.core.html#var-short-possible.3F"><code>core/short-possible?</code></a> </td><td> Checks if a phone numer is in a possible short number </td></tr>
<tr><td> <a href="phone-number.core.html#var-short-valid.3F"><code>core/short-valid?</code></a> </td><td> Checks if a phone numer is in a valid short number </td></tr>
<tr><td> <a href="phone-number.core.html#var-short-emergency.3F"><code>core/short-emergency?</code></a> </td><td> Checks if a phone numer is in an emergency number </td></tr>
<tr><td> <a href="phone-number.core.html#var-short-to-emergency.3F"><code>core/short-to-emergency?</code></a> </td><td> Checks if a phone numer can be used to connect to an emergency </td></tr>
<tr><td> <a href="phone-number.core.html#var-short-to-emergency.3F"><code>core/short-to-emergency?</code></a> </td><td> Checks if a phone numer can be used to connect to an emergency </td></tr>
</tbody>
</table>
<h2><a href="#specs" id="specs"></a>Specs</h2>
<p>Clojure Spec is used in the phone-number library to validate data and generate property-based tests. Most of the defined specs have generators attached.</p>
<p>There are 3 groups of specs:</p>
<ul>
<li>
<p><strong>Input specs</strong>, created for easy data validation.<br />
(ns-prefix: <code>phone-number.input</code>)</p>
</li>
<li>
<p><strong>Generic specs</strong> used to describe the output data.<br />
(ns-prefix: <code>phone-number</code>)</p>
</li>
<li>
<p>Specs that are used <strong>internally</strong> to test the library for corner cases and make sure that new features or other changes won’t break anything.<br />
(ns-prefixes: <code>phone-number.arg</code>, <code>phone-number.args</code>, <code>phone-number.props</code>)</p>
</li>
</ul>
<p>This page lists the input and some of the generic specs. To use them just require <code>phone-number.spec</code>, <code>clojure.spec.alpha</code> and optionally <code>clojure.spec.gen.alpha</code>:</p>
<pre><code class="language-clojure">(require [phone-number.spec :as spec]
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen])
</code></pre>
<table>
<thead>
<tr><th> Spec Name </th><th> Data description </th></tr>
</thead>
<tbody>
<tr><td><code>:phone-number.input/region</code> </td><td> region code </td></tr>
<tr><td><code>:phone-number.input/type</code> </td><td> phone number type </td></tr>
<tr><td><code>:phone-number.input/leniency</code> </td><td> phone number leniency </td></tr>
<tr><td><code>:phone-number.input/format</code> </td><td> phone number format </td></tr>
<tr><td><code>:phone-number.input/format-global</code> </td><td> phone number format<br />(with calling code prefix) </td></tr>
<tr><td><code>:phone-number.input/format-regional</code> </td><td> phone number format<br />(without calling code prefix) </td></tr>
<tr><td><code>:phone-number.input/tz-format</code> </td><td> time zone format </td></tr>
<tr><td><code>:phone-number.input/net-code</code> </td><td> global network calling code </td></tr>
<tr><td><code>:phone-number.input/country-code</code> </td><td> country calling code </td></tr>
<tr><td><code>:phone-number.input/calling-code</code> </td><td> calling code (either global or country) </td></tr>
<tr><td><code>:phone-number.input/cost</code> </td><td> cost class of short numbers </td></tr>
<tr><td><code>:phone-number.input/native</code> </td><td> phone number in native format<br />(<code>PhoneNumber</code> object)</td></tr>
<tr><td><code>:phone-number.input/native-valid</code> </td><td> native phone number which is valid </td></tr>
<tr><td><code>:phone-number.input/string</code> </td><td> phone number as a string </td></tr>
<tr><td><code>:phone-number.input/string-global</code> </td><td> phone number as a string with a calling code </td></tr>
<tr><td><code>:phone-number.input/string-regional</code> </td><td> phone number as a string without a calling code </td></tr>
<tr><td><code>:phone-number.input/string-valid</code> </td><td> valid phone number as a string </td></tr>
<tr><td><code>:phone-number.input/string-invalid</code> </td><td> invalid phone number as a string </td></tr>
<tr><td><code>:phone-number.input/numeric</code> </td><td> phone number as natural number without calling code </td></tr>
<tr><td><code>:phone-number/info</code> </td><td> phone number as a map </td></tr>
<tr><td><code>:phone-number/info-valid</code> </td><td> valid phone number as a map </td></tr>
<tr><td><code>:phone-number/info-invalid</code> </td><td> invalid phone number as a map </td></tr>
<tr><td><code>:phone-number.input/possible</code> </td><td> possible phone number </td></tr>
<tr><td><code>:phone-number.input/impossible</code> </td><td> impossible phone number </td></tr>
<tr><td><code>:phone-number.input/unknown</code> </td><td> phone number of unknown type </td></tr>
<tr><td><code>:phone-number.input/has-region</code> </td><td> phone number with region code information </td></tr>
<tr><td><code>:phone-number.input/has-calling-code</code> </td><td> phone number with calling code </td></tr>
<tr><td><code>:phone-number.input/has-location</code> </td><td> phone number having geographical location </td></tr>
<tr><td><code>:phone-number.input/has-time-zone</code> </td><td> phone number having time zone information </td></tr>
<tr><td><code>:phone-number.input/has-known-type</code> </td><td> phone number of known type </td></tr>
<tr><td><code>:phone-number.input/mobile</code> </td><td> mobile phone number </td></tr>
<tr><td><code>:phone-number.input/fixed-line</code> </td><td> fixed-line phone number </td></tr>
<tr><td><code>:phone-number.input/toll-free</code> </td><td> toll-free phone number </td></tr>
<tr><td><code>:phone-number.input/premium-rate</code> </td><td> premium-rate phone number </td></tr>
<tr><td><code>:phone-number.input/shared-cost</code> </td><td> shared-cost phone number </td></tr>
<tr><td><code>:phone-number.input/voip</code> </td><td> VoIP phone number </td></tr>
<tr><td><code>:phone-number.input/personal</code> </td><td> personal phone number </td></tr>
<tr><td><code>:phone-number.input/pager</code> </td><td> pager number </td></tr>
<tr><td><code>:phone-number.input/uan</code> </td><td> UAN number </td></tr>
<tr><td><code>:phone-number.input/voicemail</code> </td><td> voicemail number </td></tr>
<tr><td><code>:phone-number.input/fixed-line-or-mobile</code></td><td> fixed-line or mobile number (incl. uncertain) </td></tr>
<tr><td><code>:phone-number.input/uncertain-fixed-line-or-mobile</code> </td><td> uncertain number (fixed line or mobile) </td></tr>
<tr><td><code>:phone-number.input/maybe-mobile</code> </td><td> uncertain number (fixed line or mobile) or mobile </td></tr>
<tr><td><code>:phone-number.input/maybe-fixed-line</code> </td><td> uncertain number (fixed line or mobile) or fixed-line </td></tr>
<tr><td><code>:phone-number.input/short</code> </td><td> valid short number </td></tr>
<tr><td><code>:phone-number.input/maybe-short</code> </td><td> possible short number </td></tr>
<tr><td><code>:phone-number.input.short/valid</code> </td><td> valid short number </td></tr>
<tr><td><code>:phone-number.input.short/invalid</code> </td><td> invalid short number </td></tr>
<tr><td><code>:phone-number.input.short/possible</code> </td><td> possible short number </td></tr>
<tr><td><code>:phone-number.input.short/carrier-specific</code></td><td> carrier-specific short number </td></tr>
<tr><td><code>:phone-number.input.short/info</code> </td><td> short number properties as a map </td></tr>
<tr><td><code>:phone-number.input/number</code> </td><td> phone number (with calling code or without) </td></tr>
</tbody>
</table>
<p>Phone-number also contains specs for functions, however they are intended for testing and it is <strong>NOT RECOMMENDED</strong> to enable the <strong>instrumentation</strong> in production.</p>
<p>Please note that if you intend to use phone-number’s specs in a program (not in phone-number’s REPL) you should add proper dependencies since production profile of phone-number does not depend on spec nor test library. Example, minimal <code>deps.edn</code>:</p>
<pre><code class="language-clojure">{:paths ["src" "resources"]
:deps {io.randomseed/phone-number {:mvn/version "8.12.16-1"}}
:aliases {
:dev {
:extra-deps {org.clojure/spec.alpha {:mvn/version "0.2.194"}
org.clojure/test.check {:mvn/version "1.1.0"}}
:extra-paths ["dev/src" "test"]
:jvm-opts ["-Dclojure.spec.compile-asserts=true"]}
:test {
:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}}}
</code></pre>
</div></div></div></body></html>