Home arrow Java arrow Page 3 - Validator
JAVA

Validator


The Struts framework features a built-in database for performing data validations on incoming form data. Its simple interface means that developers can focus on writing validation code; additionally, you can plug your own custom routines into Validator. This article shows you how. It is taken from chapter six of the book The Complete Reference Struts, written by James Holmes (McGraw-Hill/Osborne, 2004; ISBN: 0072231319).

Author Info:
By: McGraw-Hill/Osborne
Rating: 4 stars4 stars4 stars4 stars4 stars / 29
September 22, 2005
TABLE OF CONTENTS:
  1. · Validator
  2. · Validator Overview
  3. · Included Validations
  4. · Creating Form Beans
  5. · Configuring validation.xml
  6. · Enabling Client-Side Validations
  7. · Adding a New Validation Rule
  8. · Internationalizing Validations
  9. · Create a validation.xml File

print this article
SEARCH DEVARTICLES

Validator - Included Validations
(Page 3 of 9 )

By default, Validator comes packaged with several basic validation routines that you can use to solve most validation scenarios. As mentioned, the sample applications provided by Struts come packaged with preconfigured validator-rules.xml files that define these routines. Table 6-1 lists each of the preconfigured validations by logical name and states its purpose.


Note  Detailed information on configuring the validator-rules.xml file is found in Chapter 18.

 

 

Validation

Description

byte

Validates that the specified field contains a valid byte.

creditCard

Validates that the specified field contains a valid credit card number.

date

Validates that the specified field contains a valid date.

double

Validates that the specified field contains a valid double.

email

Validates that the specified field contains a valid e-mail address.

float

Validates that the specified field contains a valid float.

floatRange

Validates that the specified field contains a valid float and falls within the

 

specified range.

integer

Validates that the specified field contains a valid integer.

intRange

Validates that the specified field contains a valid integer and falls within the

 

specified range.

long

Validates that the specified field contains a valid long.

TABLE 6-1  Validatorís Preconfigured Validations

 

 

Validation

Description

mask

Validates that the specified field conforms to a given regular expression (or "mask").

maxlength

Validates that the string in the specified fieldís length is less than or equal to the

 

specified maximum length.

minlength

Validates that the string in the specified fieldís length is greater than or equal to

 

the specified minimum length.

range

Deprecated

 

Use the intRange validation instead.

required

Validates that the specified field contains characters other than white space

 

(i.e., space, tab, and newline characters).

requiredif

Performs the required validation on the specified field if a specified rule is met.

short

Validates that the specified field contains a valid short.

TABLE 6-1   Validatorís Preconfigured Validations (continued)


blog comments powered by Disqus
JAVA ARTICLES

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials