You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Graham <dg...@hotmail.com> on 2002/10/23 22:42:57 UTC

Validation Philosophy

I just presented Struts to my team as a strategic solution and it went very 
well.  I got beat up on the validation though and didn't have a good answer. 
  I explained how the validator works with action forms and how all your 
input is validated before it gets to the business layer but that wasn't 
sufficient.

A few people argued that they want the validation in the model objects so 
every app that uses the model must follow those rules.  They said that 
having the validation before the model didn't make sense.

I'd really appreciate any arguments against this approach (or maybe they're 
right).

Thanks,
David





_________________________________________________________________
Unlimited Internet access for only $21.95/month.  Try MSN! 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Validation Philosophy

Posted by Adam Sherman <ad...@teachandtravel.com>.
David Graham wrote:
> I just presented Struts to my team as a strategic solution and it went 
> very well.  I got beat up on the validation though and didn't have a 
> good answer.  I explained how the validator works with action forms and 
> how all your input is validated before it gets to the business layer but 
> that wasn't sufficient.
> 
> A few people argued that they want the validation in the model objects 
> so every app that uses the model must follow those rules.  They said 
> that having the validation before the model didn't make sense.

There's been some comments about this somewhere, can't remember where 
exactly...

Basically, there are two types of validation: business validation & 
input validation.

Business validation is such things as "Invalid Order ID", can't create 
an invoice for that order. Or, can't delete that user, he's owned by 
another administrator.

In put validation is "dumb", like syntax. You know, is that a phone 
number, is that an email...

For example, checking an email for valid syntax is one thing, and 
looking up the domain to make sure it exists is another.

Do I make any sense at all?

Thanks,

A.


-- 
Adam Sherman
Software Developer
Teach and Travel Inc.
+1.613.241.3103



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Validation Philosophy

Posted by Robert <rm...@bull-enterprises.com>.
This came up a lot when I was teaching and our current customers ask it
a lot too, especially with Struts. What I tell them is to validate
everywhere it makes sense. What that means is that if it makes sense to
validate via javascript, do it. If you want/need model layer validation,
do it (I prefer this anyway personally). And validate at the db layer as
well (referential integrity and such). 

We have one client that has a business model that is used across client
types (both swing and struts) and therefore they definitely have
validation in their business objects. On the struts side, they also use
validation for things like making sure an input is a number, isn't
'null', etc. which can be done at the client via javascript thus saving
a trip to the server. That would equate to input type of validation as
opposed to business validation.

If you only want to validate in one place, I would do it in the business
object as it is the most reusable (assuming you aren't using dynabeans
:-) ).

- Robert

-----Original Message-----
From: David Graham [mailto:dgraham1980@hotmail.com] 
Sent: Wednesday, October 23, 2002 3:43 PM
To: struts-user@jakarta.apache.org
Subject: Validation Philosophy

I just presented Struts to my team as a strategic solution and it went
very 
well.  I got beat up on the validation though and didn't have a good
answer. 
  I explained how the validator works with action forms and how all your

input is validated before it gets to the business layer but that wasn't 
sufficient.

A few people argued that they want the validation in the model objects
so 
every app that uses the model must follow those rules.  They said that 
having the validation before the model didn't make sense.

I'd really appreciate any arguments against this approach (or maybe
they're 
right).

Thanks,
David





_________________________________________________________________
Unlimited Internet access for only $21.95/month.  Try MSN! 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>