laravelbook/ardent — pull request #124 by carlosipe (2013-11-06 23:14:39+00:00)
Title: Validation include mutated attributes

Usually I do validations on mutated attributes. It would be nice to have it by default. What do you think?

Example: The database has two columns (`left` and `top`) to indicate coordinates. But I use a mutated attribute which returns
```
function getCoordinates(){
if($this->top && $this->left)
return "{$this->top}, {$this->left}";
}
```

And I want to validate before saving that I have coordinates
```
static $rules = array(
'coordinates' => 'required'
);
```

I know this can be solved by using more specific rules, but to be DRY I don't want to say twice that coordinates are composed by left and top (first said in the getCoordinates mutator accessor and later said in a rule validating the presence of both attributes, left and top).

It's just matter of semantics and clarity of code. In more complex situations, validating mutated attributes could result in cleaner, nicer code.