>>One option would be to use a "mode" setting in your object. If it's
set to "full" then you do complete validation. If it's set to
"nameEmail" then you only validate part of it.
I've been thinking about your suggestion of validation modes.
This is my initial attempt to validate "selected" fields:
UserBean.setFirstName("Mike")
UserBean.setLastName("Dawson")
UserBean.setValidationFields("firstName,lastName")
UserBean.validate() <-- Validates only firstname and lastname fields.
UserBean.isValid() <-- Validation will succeed.
Or this to validate "all" fields:
UserBean.setFirstName("Mike")
UserBean.setLastName("Dawson")
UserBean.validate() <-- Defaults to all fields.
UserBean.isValid() <-- Validation will fail since not all values have
been set.
>>However, before you go down that road, I'd take a second look and make
sure you're not trying to bastardize your user object simply to save
yourself some typing. If your single user entity can legitimately have
different situations where different things are required, then fine.
But if you're really using the same object to represent two distinct
entities that just happen to both be termed "user", then you're going to
run into trouble down the road trying to combine them.
In my environment, I can picture several places where I need a user
object to pass to other objects that handle a user-related object. They
should still be the same object even though they may not always populate
every instance variables. I don't see any benefit having two distinct
user objects where one has fewer fields than the other, as long as the
form, fit and function don't cause any problems.
(I may very well run into a situation where I need to create another
user-related object, but with the information I have gleaned from this
list, I think I can spot those cases before I run into too much
trouble.)
I don't mind the typing. My dad was a typing teacher. ;-)
Thanks
M!ke
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189320
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54