|
Cedric, When doing any sort of custom validation of
a given record, I would put custom validation into the specific record.
So, in validating the length of a password, that’d go in the user records’
custom validate method. In the case where you’re validating
that a specific user name has not been used, I’d also put that in the
validate method. You can easily get to the ReactorFactory via the
_getReactorFactory method. You can use that to create an instance of a
UserGateway and you could call getByFields(username=’myusername’).
If any rows are returned then add an error to the validation error collection. Does that help? Doug From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cedric Villat Phil, Thanks. I didn’t mean to be so
specific about my validation, I was just looking for an approach to validation
in general. For instance, if I want to ensure that the password is at least 6 characters.
Is this a check that should be put in the Record object somewhere, or in the
controller? My problem with the controller, is that anywhere I set the
password, I have to do my check, but if it was in a record it could be done in
1 place. How are you guys doing this validation? Cedric From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Phil Cruz You could do a "pre-check"
in the controller but that wouldn't guarantee uniqueness because another user
with that email could be inserted after that check and before you try to
insert. The only way to guarantee is to put a unique constraint in the
database and catch the exception. You can look at the Mach-II sample
application to see one way to implement that. Look at the
UserListener.cfc:: On 2/24/06, Cedric
Villat <[EMAIL PROTECTED]>
wrote: Just
a quick question about validating records. I have a UserRecord that has a
Username, password, and email. Once of the requirements is that the Username
must be unique. Should I check for uniqueness in a controller before I call the
save() method, or should I use a Validate() method that checks for the
uniqueness? If I used a Validate() method, where does it go? Is it ok to
reference a UserGateway to call an Exists() function? Just
wondering where to do this sort of validation. Cedric -- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
|
- [Reactor For CF] Validating records Cedric Villat
- Re: [Reactor For CF] Validating records Phil Cruz
- RE: [Reactor For CF] Validating records Cedric Villat
- RE: [Reactor For CF] Validating records Doug Hughes
- RE: [Reactor For CF] Validating records Cedric Villat
- RE: [Reactor For CF] Validating record... Doug Hughes
- RE: [Reactor For CF] Validating re... Cedric Villat
- [Spam] RE: [Reactor For CF] V... Jim McMullen
- RE: [Spam] RE: [Reactor For C... Cedric Villat
- Re: [Reactor For CF] Validating records Sean Corfield

