The rules are currently grouped by validator:
array(
array('field1, field2', 'required'),
array('field1', 'email'),
)
- Would it be better if separated?
array(
array('field1', 'required'),
array('field1', 'email'),
array('field2', 'required'),
)
- Or grouped by field (this would actually need more arrays)?
array(
array('field1', array('required', 'email')),
array('field2', array('required')),
)
- Or grouped by scenario, then separated like (1)?
array(
'*' => array(
array('field1', 'required'),
array('field1', 'email'),
array('field2', 'required'),
),
)
- Or grouped by scenario, then grouped by field like (2)?
array(
'*' => array(
array('field1', array('required', 'email')),
array('field2', array('required')),
),
)
Or is it good as it is? Please leave your opinion.
I’d prefer it more granular, like the version 3.
The reason is because it is easier to manipulate the rules when you extend the model.
It is also better to reuse and override rules when merging the arrays for the scenarios.
Also, see this related thread.