I've encountered many new CakePHP users that were a bit confused by the 'allowEmpty' option in validation rules. Thinking about this issue, I must say that I agree.
'allowEmpty' is confusing because it's both an 'option' for a validation rule (it can be combined with another rule), *and *can be used as a 'validation rule' on itself. When it *is* used on itself, it seems to duplicate the 'notEmpty()' Core Validation Rule (). Another side-effect of the 'allowEmpty' option, is that (by default) it doesn't work in combination with custom validation rules (http://stackoverflow.com/questions/15570376/custom-validation-is-not-taking-allowempty-option) If I'm not overlooking things, all validate arrays below basically do the same: public $validate = array( 'name' => array( 'allowEmpty' => false, ); ); // Simple notation, no options provided public $validate = array( 'name' => 'notEmpty'; ); // Array notation, no options provided public $validate = array( 'name' => array( 'rule' => 'notEmpty' ); ); My suggestion is to remove the 'allowEmpty' option. (or at least make sure that it is taken into account for custom validation-methods on a Model). If this option is to be removed, an exception should be thrown that a deprecated option is used to prevent users from unwanted behavior :) I'm new to this group (not new to CakePHP), so I don't know if this is the proper channel to make feature requests/suggestions in this location. If not, hints on where to file these kind of requests are welcome! -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
