CStringValidator allowEmpty=>false

I’ve just noticed that if I use CStringValidator with allowEmpty => false and an attribute’s value is an empty string, then the validator doesn’t show any error. In a combination with CRequiredValidator it works well and shows “Attribute can’t be blank” message:

array('name', 'required'),

array('name', 'length', 'max'=>100, 'allowEmpty'=>false),

I just wonder if it is an expected behavior or I’m missing something :huh:

Should not make a difference whether what’s not required is empty or not :rolleyes:


You are right, but it doesn’t look intuitive to me when I disallow a field to be empty, but it can be empty anyway :) Had to spend some time to figure this out…