commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <>
Subject Re: [validator] BSF script validator
Date Mon, 24 May 2004 12:45:19 GMT
Go ahead an open a bugzilla ticket for code to be attached to.  If we're
going to distribute validators like this they should probably be in a
separate download so the core validator framework stays separate and we
can manage dependencies better.


--- Don Brown <> wrote:
> I wrote a validator that uses scripting snippets to determine validity. 
> The validator uses Jakarta BSF so supports any scripting language 
> supported by BSF like BeanShell, JavaScript, Jython, Groovy (I believe),
> etc.
> I was starting to refactor out my app's validation code to be usable by 
> commons-validator, when I realized most of the resulting validations 
> ended up being one line.  For example, to make sure a particular 
> employee existed, the validation was simply "empFacade.getEmployee(key) 
> != null".  Rather than writing a ton of one line validator or shoving 
> them all into one umbrella validator, I decided to write this validator.
> Here is an example of its use:
> <field property="value" depends="bsf">
>   <var>
>     <var-name>eval</var-name>
>     <var-value>value.equals("foo")</var-value>
>   </var>
> </field>
> The validator works and the unit tests pass, but I'm still working on a 
> clean way to pass it business objects.  Right now, if you want to put 
> variables in the scope, you need to create your own BSFManager and 
> BSFEngine beforehand and add them as Validator parameters.  For simple 
> cases with just BeanShell, neither are required, just the usual target 
> object and Field.
> Again, I can submit the code, unit tests, and patches if needed.  I 
> certainly do appreciate how flexible validator is to be able to support 
> many types of implementations.
> Don
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Yahoo! Domains  Claim yours for only $14.70/year 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message