--- __matthewHawthorne <[EMAIL PROTECTED]> wrote:
> I have a simple validation mechanism that I often use for unit testing,
> and I'm curious to see if it can be fit into [validator] somehow.
> 
> I defined a Validator interface, which contains methods which can return
> a boolean or throw an exception.  Usually in my tests I prefer fail-fast
> behavior, so I use the latter two.
> 
> Validator
>      boolean isValid(Object)
>      boolean areAllValid(Collection)
>      void validate(Object) throws ValidationException
>      void validateAll(Collection) throws ValidationException
> 
> I then created a BeanValidator class which accepts a String array in its
> constructor which contains field names.  It expects the object in 
> question to be a bean, and throws an error if any of the field names 
> have null values.  I use [beanutils] to do this.  The current behavior 
> only validates if the value exists or not, but I would imagine more 
> specific constraints such as number ranges, regexs, etc. may be 
> necessary in the future.
> 
> I've taken a look at [validator] a few times, but I've never been able
> to get a firm understanding of how to use it.  My needs are not HTML or
> form based at all.

There is an example class in CVS that shows how to use Validator in a
non-web, non-Struts application.

> 
> 
> Questions:
> 
> 1) Is there a way to do what I'm doing with the current code in
> [validator]?
> 
> 2) If not, is there any interest in creating a more general validation 
> system, which can be used in non-form based environments?

Validator uses HTML form terminology but it really is a generic bean
property validation system.  Struts just happens to pass it ActionForm
beans representing and HTML form.  One goal for Validator 2.0 is to change
the form centered terminology to bean/property terms in the code and xml
configuration.

David

> 
> 
> I think that a simple validation framework for beans and simple objects
> would be great and very useful.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to