Skip to content

Commit 3663172

Browse files
author
John Keyes
committed
- a small start on documenting the validators
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@191008 13f79535-47bb-0310-9956-ffa450edef68
1 parent 39591cd commit 3663172

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

xdocs/manual/validators.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,40 @@
2323

2424
<body>
2525
<section name="Validators">
26+
<p>
27+
CLI2 provides a mechanism to validate argument values. The <code>Validator</code>
28+
interface must be implemented to create an argument validator. This interface has
29+
a single method <code>validate(java.util.List values) throws InvalidArgumentException</code>.
30+
</p>
31+
<p>
32+
CLI2 has some standard validators included. They validate the following:
33+
</p>
34+
<ul>
35+
<li>Java class</li>
36+
<li>date</li>
37+
<li>enumeration</li>
38+
<li>file path</li>
39+
<li>number</li>
40+
<li>URL</li>
41+
</ul>
42+
2643
<img src="../images/validators.jpg"/>
2744

2845
<subsection name="ClassValidator">
46+
<p>
47+
The <code>ClassValidator</code> can validate a value using three criteria:
48+
</p>
49+
<ol>
50+
<li>the value adheres to the Java Language Specification rules</li>
51+
<li>the class specified by the name is loadable</li>
52+
<li>the class specified by the name can be instantiated</li>
53+
</ol>
54+
<source>// 1.
55+
ClassValidator validator = new ClassValidator();
56+
// 2.
57+
validator.setLoadable(true);
58+
// 3.
59+
validator.setLoadable(true);</source>
2960
</subsection>
3061
<subsection name="DateValidator">
3162
</subsection>

0 commit comments

Comments
 (0)