From: John C. <oo...@ro...> - 2003-03-03 01:42:26
|
Hey everyone, I have a class called NewUserRegistrationRequest which is a simple javabean that will transport the data submited by a user from a webpage (not implemented yet) to my business object. My business object has a method called registerUser(NewUserRegistrationRequest request) which handles this use case. My dilema is how to handle syntatic and semantic validation for this particular use case which will most likelly dictate how I handle things in other use cases. The validations that I need are 1) making sure the Request object is properlly initiallized and that none of the properties are null 2) making sure that username is unique 3) making sure that email address is unique 4) username and password length rules 5) making sure that an email address looks like an email address 6) making sure that a default user access level is assigned to this new user 7) * allow for futher rules to be defined without a huge impact in the application. For example, I may want to have a rule which sends out an email to the new user in order to validate the registration at a later date. The way I see it, 1,4 and 5 are syntatic rules and 2,3, and 6 are semantic rules (to use the terms in the book) Some other requirments would be to allow for internatiolization of messages, and it would be nice to also have javascript generated or associated with this validation, so that both client side and server side validation could be done if wanted. With this last requirement, it's not really something I desire. I personaly do not trust client side validation, so I usualy do all validation on the server side. So if I don't get to that, its no big deal. These validations should hopefully only occour in once place. But what is that place? The validator interface looks like it's where I should start but I don't completly understand how it should work overall. Should I invoke this validator in my business method? My thoughts tell me yes that that's what I should be doing. But what about sending errors out from the validator back to calling code without "poluting" my business interfaces? How would that work? Any ideas suggestions or comments would be greatly appriciated. Thanks, John |