In my humble opinion, the User absolutely **should** know how to validate
itself, including validating a new password.  Otherwise, exactly as you've
suggested, you end up with a bunch of bloated structs called CFCs floating
around your application.

Like anything, there is more than one way to skin a cat, but here's a bit of
pseudo code from my controller that shows how I handle a password change.

user = getSecurityService().getSessionUser();
if ( user.isPassword( event.getValue("currentPassword") ) {
    clone = user.clone();
    clone.setPassword( event.getValue("password") );
    clone.setConfirmPassword( event.getValue("confirmPassword") );

    if ( clone.validate( context: "change password" ) {
         clone.save();
    } else {
         // send them back to the form with validation error message(s)
    }
}

HTH

On Mon, Oct 20, 2008 at 10:26 AM, Alan Livie <[EMAIL PROTECTED]> wrote:

> I keep falling into the 'anemic domain model' trap and for once I want this
> User to be a genius :-) I have too many simple beans with dumb getters and
> setters and service methods with all the good stuff.
> It must end!
>
> As far as my User goes, it can be in an invalid state until the save()
> method calls validate() before persisting the data if validation passes. So
> the User can have an invalid email address until validate() is called.
>
> Alan
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to