Take a look at the project validator files. They have a structure whereby there's a set of validation methods. In general they have this structure:
There is a validate() method validates the entire object by calling methods to validate each of the fields in the object (for example, validateFirstName()). This field-specific validation method validates the field by calling methods to validate specific details about the field (for example, that it's too long, that it's provided, that it's the correct data type). Any one of these methods can be overridden. This means that if you wanted to validate some specific details about a field that you could override the field validator method to call the super object's field validator method and then your own method to validate a specific detail of an object. For example, in the ReactorBlog sample app the UserValidator has been customized. See /blog/data/Validator/UserValidator.cfc. This customization makes sure that the username is unique. You'll note that I override the validateUsername method (which is in the project UserValidator). It calls user.validateUserName() and then calls validateUsernameIsUnique. This method uses a gateway to make sure that the provided username hasn't been used before. If I wanted I could also validate any other information I want following this same pattern. Doug -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cedric Villat Sent: Monday, July 03, 2006 12:34 PM To: [email protected] Subject: RE: [Reactor for CF] Validate records Joao, Thanks for the explanation. Makes sense. What would I do if I wanted to add additional validation? Before, I would just continue adding errors to the ValidationErrorCollection object. What would I do now? Is it as easy as overriding the validate() method (making sure to call before/afterValidate()), and add my own checks? Cedric -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of João Fernandes Sent: Monday, July 03, 2006 9:25 AM To: [email protected] Subject: RE: [Reactor for CF] Validate records Cedric, You can check if there is errors using myRecord.hasErrors() after doing myRecord.validate(); The _getErrorCollection().getErrors() will return an array of errors occurred during validation. João Fernandes Dep. Informática - Área de Desenvolvimento Cofina media Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL Tel (+351) 213 185 200 . Fax (+351) 213 540 370 [EMAIL PROTECTED] -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cedric Villat Sent: segunda-feira, 3 de Julho de 2006 17:14 To: [email protected] Subject: RE: [Reactor for CF] Validate records Tom, That's what I figured, but looking at the AbstractRecord object, validate() returns void, which means I have no additional object I can tack errors onto. Does validate() throw an error when validate fails, or something? Cedric -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Chiverton Sent: Monday, July 03, 2006 1:10 AM To: [email protected] Subject: Re: [Reactor for CF] Validate records On Monday 03 July 2006 05:03, Cedric Villat wrote: > Basically, I want to override the validate() method to add some > additional logic. What is the proper way of doing this with the latest > version of Reactor? I would guess you create a method called 'validate', have it call super.validate() and then do your additional checks. -- Tom Chiverton -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [email protected] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [email protected] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

