commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Brown <>
Subject [validator] BSF script validator
Date Sat, 22 May 2004 01:54:33 GMT
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), 

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">

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.


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

View raw message