commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romero, Ron" <Ron.Rom...@txaccess.com>
Subject Validator By Name
Date Mon, 15 Aug 2005 16:19:43 GMT
I'm working on a large project using Commons Validator, using
exclusively the regex validation.  I want to administer all my regexes
from a single location.  I don't want each developer to have to write
their own regex for, e.g., a first name or a U.S. phone number.  I want
to write the regex in one place and have all the developers use that
regex by name.  That way I can ensure it's correct and consistent, and I
can change it in one place.
 
So, I would like a Commons Validator method that is passed in a name of
a validator.  Then it would look up that validator regex and apply that.
Something like:
 
        public bool isValidByName(String text, String name);
 
There would be an XML file that defines the validators:
 
        <validator type="byName" name="phoneNumber" 
			 regex="(1[ -+]*)?\d{3}\-?\d{3}-?\d{4}" />
 
Design ande development should be pretty straight-forward.  Just a
lookup by name, then you pass it to matchesRegex().  
 
On a longer term view, we could eventually make the ByName validator
take any type of validation, or any combination there-of.  So I could,
e.g., make an email field that only allows France email addresses.  But
that gets trickier than the regex-by-name, and, frankly, it's more than
I need right now.
 
So, is this worthwhile functionality?  Do I have any holes?  I could
probly write some or all of this myself, but I'd like discussion on what
it needs to do and what the basic approach would be.  And does this even
belong in JCL?  I tried to suggest it to Shale, and Craig suggested it
belongs in JCL.
 
 
Thanks,
 
Ron Romero

Texas ACCESS Alliance
Work 512-732-5827
AIM: ronzromero
Ron.Romero@txAccess.com

 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message