cmdr
Check-in [49d0a10137]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:49d0a101375ce72584b6063cebf0f58446aeb940
User & Date: aku 2014-02-13 05:39:45
Original Comment:
Context
2014-02-17
20:19
Extended debug narrative at method returns. check-in: c6dc11d2a1 user: andreask tags: trunk
2014-02-13
05:39
Extended the set of common validation types, added "percent" (double limited to [0,100]). Updated documentation. check-in: 49d0a10137 user: aku tags: trunk
2014-02-12
23:29
Extended the set of common validation types, added "double". Bumped cmdr::validate to 1.2 check-in: c843b9c1dd user: andreask tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/parts/vtypes_std.inc.

1
2
3
4
5
6


7
8
9
10
11
12
13
[list_begin definitions]
[def boolean]		Completable. Accepts a Tcl boolean.
[def identity]	
[def pass]	
[def str]		Infinite.    Accepts all strings.
[def integer]		Infinite.    Accepts a Tcl integer.


[def rdirectory]	Completable. Accepts a readable directory (path).
[def rfile]		Completable. Accepts a readable file (path).
[def rpath]		Completable. Accepts a readable path.
[def rwdirectory]	Completable. Accepts a read/writable directory (path).
[def rwfile]		Completable. Accepts a read/writable file (path).
[def rwpath]		Completable. Accepts a read/writable path.
[list_end]





|
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[list_begin definitions]
[def boolean]		Completable. Accepts a Tcl boolean.
[def identity]	
[def pass]	
[def str]		Infinite.    Accepts all strings.
[def integer]		Infinite.    Accepts a Tcl integer number.
[def double]		Infinite.    Accepts a Tcl double number.
[def percent]		Infinite.    Accepts a Tcl double number in the range [lb]0,100[rb].
[def rdirectory]	Completable. Accepts a readable directory (path).
[def rfile]		Completable. Accepts a readable file (path).
[def rpath]		Completable. Accepts a readable path.
[def rwdirectory]	Completable. Accepts a read/writable directory (path).
[def rwfile]		Completable. Accepts a read/writable file (path).
[def rwpath]		Completable. Accepts a read/writable path.
[list_end]

Changes to embedded/man/files/cmdr_validate.n.

274
275
276
277
278
279
280
281






282
283
284
285
286
287
288
.TP
pass
.TP
str
Infinite\&.    Accepts all strings\&.
.TP
integer
Infinite\&.    Accepts a Tcl integer\&.






.TP
rdirectory
Completable\&. Accepts a readable directory (path)\&.
.TP
rfile
Completable\&. Accepts a readable file (path)\&.
.TP







|
>
>
>
>
>
>







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
.TP
pass
.TP
str
Infinite\&.    Accepts all strings\&.
.TP
integer
Infinite\&.    Accepts a Tcl integer number\&.
.TP
double
Infinite\&.    Accepts a Tcl double number\&.
.TP
percent
Infinite\&.    Accepts a Tcl double number in the range [0,100]\&.
.TP
rdirectory
Completable\&. Accepts a readable directory (path)\&.
.TP
rfile
Completable\&. Accepts a readable file (path)\&.
.TP

Changes to embedded/www/doc/files/cmdr_validate.html.

148
149
150
151
152
153
154
155




156
157
158
159
160
161
162
<dt>identity</dt>
<dd></dd>
<dt>pass</dt>
<dd></dd>
<dt>str</dt>
<dd><p>Infinite.    Accepts all strings.</p></dd>
<dt>integer</dt>
<dd><p>Infinite.    Accepts a Tcl integer.</p></dd>




<dt>rdirectory</dt>
<dd><p>Completable. Accepts a readable directory (path).</p></dd>
<dt>rfile</dt>
<dd><p>Completable. Accepts a readable file (path).</p></dd>
<dt>rpath</dt>
<dd><p>Completable. Accepts a readable path.</p></dd>
<dt>rwdirectory</dt>







|
>
>
>
>







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<dt>identity</dt>
<dd></dd>
<dt>pass</dt>
<dd></dd>
<dt>str</dt>
<dd><p>Infinite.    Accepts all strings.</p></dd>
<dt>integer</dt>
<dd><p>Infinite.    Accepts a Tcl integer number.</p></dd>
<dt>double</dt>
<dd><p>Infinite.    Accepts a Tcl double number.</p></dd>
<dt>percent</dt>
<dd><p>Infinite.    Accepts a Tcl double number in the range [0,100].</p></dd>
<dt>rdirectory</dt>
<dd><p>Completable. Accepts a readable directory (path).</p></dd>
<dt>rfile</dt>
<dd><p>Completable. Accepts a readable file (path).</p></dd>
<dt>rpath</dt>
<dd><p>Completable. Accepts a readable path.</p></dd>
<dt>rwdirectory</dt>

Changes to validate.tcl.

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
119
120
121
122
123
124
125


























126
127
128
129
130
131
132

namespace eval ::cmdr {
    namespace export validate
    namespace ensemble create
}

namespace eval ::cmdr::validate {
    namespace export boolean integer double identity pass str \
	rfile rwfile rdirectory rwdirectory rpath rwpath
    #namespace ensemble create

    # For external v-types relying on them here.
    namespace import ::cmdr::validate::common::fail
    namespace import ::cmdr::validate::common::complete-enum
}

................................................................................
proc ::cmdr::validate::integer::validate {p x} {
    debug.cmdr/validate {}
    if {[string is integer -strict $x]} { return $x }
    fail $p INTEGER "an integer" $x
}

# # ## ### ##### ######## ############# #####################
## Any float

namespace eval ::cmdr::validate::double {
    namespace export default validate complete release
    namespace ensemble create
    namespace import ::cmdr::validate::common::fail
}

................................................................................
    return {}
}
proc ::cmdr::validate::double::validate {p x} {
    debug.cmdr/validate {}
    if {[string is double -strict $x]} { return $x }
    fail $p DOUBLE "a double" $x
}



























# # ## ### ##### ######## ############# #####################
## Any string

namespace eval ::cmdr::validate::identity {
    namespace export default validate complete release
    namespace ensemble create







|
|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

namespace eval ::cmdr {
    namespace export validate
    namespace ensemble create
}

namespace eval ::cmdr::validate {
    namespace export boolean integer double percent identity \
	pass str rfile rwfile rdirectory rwdirectory rpath rwpath
    #namespace ensemble create

    # For external v-types relying on them here.
    namespace import ::cmdr::validate::common::fail
    namespace import ::cmdr::validate::common::complete-enum
}

................................................................................
proc ::cmdr::validate::integer::validate {p x} {
    debug.cmdr/validate {}
    if {[string is integer -strict $x]} { return $x }
    fail $p INTEGER "an integer" $x
}

# # ## ### ##### ######## ############# #####################
## Any double

namespace eval ::cmdr::validate::double {
    namespace export default validate complete release
    namespace ensemble create
    namespace import ::cmdr::validate::common::fail
}

................................................................................
    return {}
}
proc ::cmdr::validate::double::validate {p x} {
    debug.cmdr/validate {}
    if {[string is double -strict $x]} { return $x }
    fail $p DOUBLE "a double" $x
}

# # ## ### ##### ######## ############# #####################
## Any double in [0,100]

namespace eval ::cmdr::validate::percent {
    namespace export default validate complete release
    namespace ensemble create
    namespace import ::cmdr::validate::common::fail
}

proc ::cmdr::validate::percent::release  {p x} { return }
proc ::cmdr::validate::percent::default  {p}  {
    debug.cmdr/validate {}
    return 0
}
proc ::cmdr::validate::percent::complete {p x} {
    debug.cmdr/validate {} 10
    return {}
}
proc ::cmdr::validate::percent::validate {p x} {
    debug.cmdr/validate {}
    if {[string is double -strict $x] &&
	($x >= 0) &&
	($x <= 100)} { return $x }
    fail $p PERCENT "a percentage" $x
}

# # ## ### ##### ######## ############# #####################
## Any string

namespace eval ::cmdr::validate::identity {
    namespace export default validate complete release
    namespace ensemble create