commons-dev CLI2 - Validators

CLI2 provides a mechanism to validate argument values. The Validator interface must be implemented to create an argument validator. This interface has a single method validate(java.util.List values) throws InvalidArgumentException.

CLI2 has some standard validators included. They validate the following:

The ClassValidator can validate a value using three criteria:

  1. the value adheres to the Java Language Specification rules
  2. the class specified by the name is loadable
  3. the class specified by the name can be instantiated
// 1. ClassValidator validator = new ClassValidator(); // 2. validator.setLoadable(true); // 3. validator.setLoadable(true);