|
Hi Dan, Waht I have done, is the
following: -
in the ‘reactor-created’ cfc’s find the validator
cfc for the object that you want to add to. -
In this cfc, add a function for the field you want to add to, for
instance validateUser -
First call <cfset super.validateEmail(arguments.UserRecord,
arguments.ErrorCollection) /> to run all the reactor validation -
Then add calls to your own functions, that you can add below the
function you are in know. My CFC looks like this: <cfcomponent
hint="I am the validator object for the User object. I am generated, but
not overwritten if I exist. You are safe to edit me." extends="reactor.project.cello.Validator.UserValidator"> <!---
Place custom code here, it will not be overwritten ---> <!---
validateEmail ---> <cffunction
name="validateEmail" access="public" hint="I validate
the Email field" output="false"
returntype="reactor.util.ErrorCollection"> <cfargument
name="UserRecord" hint="I am the UserRecord to validate."
required="no"
type="reactor.project.cello.Record.UserRecord" /> <cfargument
name="ErrorCollection" hint="I am the error collection to
populate. If not provided a new collection is created."
required="no" type="reactor.util.ErrorCollection"
default="#createErrorCollection(arguments.UserRecord._getDictionary())#"
/> <cfset
super.validateEmail(arguments.UserRecord, arguments.ErrorCollection) /> <!---
validate Email is unique ---> <cfset
validateEmailIsUnique(arguments.UserRecord, arguments.ErrorCollection)> <!---
validate Email is correct ---> <cfset
validateEmailIsCorrect(arguments.UserRecord, arguments.ErrorCollection)> <cfreturn
arguments.ErrorCollection /> </cffunction> <!---
validateEmailIsUnique ---> <cffunction
name="validateEmailIsUnique" access="public" hint="I
validate that the email field is unique" output="false"
returntype="reactor.util.ErrorCollection"> <cfargument
name="UserRecord" hint="I am the UserRecord to validate."
required="no"
type="reactor.project.cello.Record.UserRecord" /> <cfargument
name="ErrorCollection" hint="I am the error collection to
populate. If not provided a new collection is created."
required="no" type="reactor.util.ErrorCollection"
default="#createErrorCollection(arguments.UserRecord._getDictionary())#"
/> <cfset
var UserGateway = _getReactorFactory().createGateway("User") /> <!---
insure that another user with the same username does not already exist ---> <cfif
UserGateway.validateEmail(arguments.UserRecord.getUserId(),
arguments.UserRecord.getEmail())> <cfset
arguments.ErrorCollection.addError("User.email.duplicateEmail") /> </cfif> <cfreturn
arguments.ErrorCollection /> </cffunction> <!---
validateEmailIsCorrect ---> <cffunction
name="validateEmailIsCorrect" access="public" hint="I
validate that the email field is a correct emailaddress"
output="false"
returntype="reactor.util.ErrorCollection"> <cfargument
name="UserRecord" hint="I am the UserRecord to validate."
required="no"
type="reactor.project.cello.Record.UserRecord" /> <cfargument
name="ErrorCollection" hint="I am the error collection to
populate. If not provided a new collection is created."
required="no" type="reactor.util.ErrorCollection"
default="#createErrorCollection(arguments.UserRecord._getDictionary())#"
/> <cfif
NOT isValid("Email", arguments.UserRecord.getEmail())> <cfset
arguments.ErrorCollection.addError("User.email.InCorrectEmail") /> </cfif> <cfreturn
arguments.ErrorCollection /> </cffunction> </cfcomponent> I believe this is copied
from the MG / Reactor Blog sample from the Reactor site. Good luck! Erik-Jan Van:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Dan Vega Does anyone have an example of custom validation? I do not wish to
overwrite the curret validation,just to extend it. I have a userRecord that
contains a bunch of basic info that reactor is already validating. I would like
to aded custom validation so i can find out if -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [email protected] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
- [Reactor for CF] Extended Validation Dan Vega
- RE: [Reactor for CF] Extended Validation Erik-Jan Jaquet
- Re: [Reactor for CF] Extended Validation Dan Vega
- RE: [Reactor for CF] Extended Validation Doug Hughes
- Re: [Reactor for CF] Extended Validation Dan Vega
- Re: [Reactor for CF] Extended Validation Dan Vega
