File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments