Author: niallp Date: Tue Dec 12 09:50:05 2006 New Revision: 486253 URL: http://svn.apache.org/viewvc?view=rev&rev=486253 Log: Update routines documentation for CodeValidator
Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/routines/package.html Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/routines/package.html URL: http://svn.apache.org/viewvc/jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/routines/package.html?view=diff&rev=486253&r1=486252&r2=486253 ============================================================================== --- jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/routines/package.html (original) +++ jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/routines/package.html Tue Dec 12 09:50:05 2006 @@ -46,6 +46,7 @@ <li>4.1 <a href="#other.overview">Overview</a></li> <li>4.2 <a href="#other.regex">Regular Expression validation</a></li> <li>4.3 <a href="#other.checkdigit">Check Digit Validation/Calculation</a></li> + <li>4.4 <a href="#other.code">General Code Validation</a></li> </ul></li> </ul> @@ -419,6 +420,8 @@ using Java 1.4+ regular expression support</li> <li><a href="#other.checkdigit">Check Digit</a> - validates/calculates check digits (i.e. EAN/UPC, credit card, ISBN).</li> + <li><a href="#other.code">Code Validation</a> - provides generic + code validation - format, minimum/maximum length and check digit.</li> </ul> <a name="other.regex"></a> @@ -575,6 +578,39 @@ </pre> + +<a name="other.code"></a> +<h3>4.4 General Code validation</h3> +<p> + <a href="CodeValidator.html">CodeValidator</a> provides a generic + implementation for validating codes. It performs the following + validations on a code: +</p> +<ul> + <li><b>Format</b> - the format of the code is validated using + a <i>regular expression</i> (see <a href="RegexValidator.html">RegexValidator</a>).</li> + <li><b>Length</b> - the minimum/maximum length of the code is + checked - after being parsed by the regular expression - with which + <i>format</i> characters can be removed with the use of + <i>non-capturing</i> groups.</li> + <li><b>Check Digit</b> - a <a href="checkdigit/CheckDigit.html">CheckDigit</a> + routine checks that code's check digit is valid.</li> +</ul> +<p> + For example to create a validator to validate EAN-13 codes (numeric, + with a length of 13): +</p> +<pre> + + // Create an EAN-13 code validator + CodeValidator validator = new CodeValidator("^[0-9]*$", 13, EAN13CheckDigit.INSTANCE); + + // Validate an EAN-13 code + if (!validator.isValid(code)) { + ... // invalid + } + +</pre> </body> </html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]