Luis Majano Forums Notification: Post to Form Validation

Title: RE: Form Validation
Thread: Form Validation
Forum: Need Help?
Conference: ColdBox
User: lmajano

I can see the beanfactory populating the bean via the memento. What it populated
it with, I think it should be up to the bean itself to determine if its data is
valid or not. What if you have rules on your validation, such as if age gt 5 or
age lt 3. Then you bean must determine if its populate data is correct.

How
would this be achieved via the validator. I guess what I am not seeing is how a
validator would do all this. Would you create one validator object for every
single domain model entity?

I don't think that the bean itself should be that
"DUMB" in which it doesn't care when data gets injected to itself. I guess you
can make it dumb enough to have another entity validate it, but In my opinion
that is going over the top and will probably end up with 100 of objects. Why
can't the domain objects be robust enought to do their own validations. The
validations are not on the outside world, but on themselves. The object is
conscious of own internal state. This would decrease your domain objects,
because wether you like it or not, you are going to have to create validators
for every domain model object you want to validate.

But, who know, maybe a
validator can do a better job. I just don't see how? can you give some example
of a validator?

http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=099E0187-123F-6116-421FA3B9B2F4006A