>> MO, data validation should not be performed within the model
but rather in the controller
There is definitively many opinions about Validation in MVC, but I
still don't agree with your statement. I want a solution that does not
oblige me to rewrite my validation code each time my View changes -
either I change the UI logic or the client technology -, since
controller is tighly bound to the view.
Model has all the info needed to performs the validation, and
validation is purely domain logic, no ?
Dale McNeill a écrit :
IMO,
data validation should not be performed within the model but rather in
the controller. The controller could query the Table/Row for validator
objects but its the controller that should perform all the validating
of data.
One thing that I would like to see in a future Zend_Db_Table is the
storage of the entire "describe <table>" rather than only storing
the column names. Why? Well I've changed the Table to store this
information so that the controller can query the Table for the
fundamental validator objects. A "varchar(30)" can provide a validator
that restricts the the length to 30 characters; a "int(10)" can provide
an integer validator that restricts the maximum value to a 10 digit
signed integer. I think in general the results of the describe table
is very useful and certainly worth storing all the information. It
could even be used to set the default values of any unset columns when
performing an insert.
Dale
Stuardo -StR- Rodríguez wrote:
On Wednesday 27 September 2006 00:47, Victor
Bolshov wrote:
Could you please tell in more detail - what
you mean by "a model in MVC"?
I mean a model, in the context of Model-View-Controller. As you can see
in http://en.wikipedia.org/wiki/Model-view-controller
<blockquote>
Model: The domain-specific representation of the information on which
the application operates. The model is another name for the domain
layer. Domain logic adds meaning to raw data (e.g., calculating if
today is the user's birthday, or the totals, taxes and shipping charges
for shopping cart items).
</blockquote>
So.. from where I see.. the controller should create a model to get
data or to return data, from wherever you want (DB, XML, RPC, log,
etc). The controller should know "the action" what should be done, the
bussiness logic. The model should know what to do with the data,
validate the data, and all what is related with data.
Now, I do not see any solution for that in ZF and I thought
Zend_Db_Table could be use as a solution, but I was wrong and I started
the post to see if anyone had the same idea and if anyone has solved
that.
I said "Model in MVC" to let people understand the context, so no one
gets confused with "a model/guide to follow" or "a hot-long-legs-model"
|