Welcome Guest, Not a member yet? Register   Sign In
Poll: Do we need new solution for Form filtering and validation?
You do not have permission to vote in this poll.
Yes
53.33%
16 53.33%
No
36.67%
11 36.67%
maybe
10.00%
3 10.00%
Total 30 vote(s) 100%
* You voted for this item. [Show Results]

Input filtering and Form validation
#16

(04-08-2015, 09:31 AM)sv3tli0 Wrote: Form validation inside a model is not acceptable for me. You don't send requests to models to validate them, this is a joke I hope.

The current rules are nice I don't say that they should be replaced.
What I mean is to move all things outside the controller into a separate Form type class which will handle the form request and it will apply all filters/validation rules (which will contains all callback methods..).
This will clean your controllers and you will have just to call this form element(class) and to run the validation command(method) nothing more..

Just food for a thought:

I'm not validating anything in the controller nor in the model

Validating an array other than post did the trick for me

because i've separated Data Objects.
Those objects react based on the different Request Types by creating an array which are passed to the form validation object

And those objects are handled between models and controllers  - thats the reason why i've extended my folder structure to (controllers/models/objects/views)

In my opinion the process of data validation has to be separated from models AND controllers - its something totally different - and those actions tend to blow up your models or controllers (depending on your preferred method)
Reply


Messages In This Thread
Input filtering and Form validation - by sv3tli0 - 04-06-2015, 10:08 PM
RE: Input filtering and Form validation - by sintakonte - 04-09-2015, 07:38 AM
RE: Input filtering and Form validation - by cjj - 04-09-2015, 09:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB