Re:Show HN: Laravel 3.1 PHP Framework. Includes awesome ORM.
by ShawnMcCool on Tuesday March 27, 2012 @01:52PM
(#3762763)
Laravel isn't the kind of framework to lock you into a specific way of doing things. It's different than what you may expect if you're coming from Symfony, Kohana, CodeIgniter, or Fuel.
There's no reason to tie a validation system into a model. That's enough justification for it not to be done. You have the flexibility to implement it easily in whatever way you see fit.
Re:Show HN: Laravel 3.1 PHP Framework. Includes awesome ORM.
by mgkimsal on Wednesday March 28, 2012 @08:49PM
(#3769090)
You can get reductionist and say there's no reason to do anything. The fact is, most of the time when people have models that represent things, there are going to be basic validation rules to represent standard constraints ("email has to be valid", "fields x/y/z can't be null", etc). Those constraints are specific to the concept of the model itself, outside of any relations it may have, or uses it may have in the rest of the app. To me, that's reason enough to provide for a validation system in a model in framework.
Hell - why have models? There's no reason to tie a model in to a framework - just be flexible and do it however you want, right?
I'm assuming you could put a static $validationRules on a model and grab it in a controller for validation, but that it's not described/recommended/defaulting to that behaviour is a bit disappointing.