1
我有以下驗證器功能。PHPActiveRecord allow_blank,allow_null無法驗證
static $validates_size_of = array(
array('contactfirstname' , 'within' => array(1,50), 'allow_null' => true),
array('contactlastname' , 'within' => array(1,50), 'allow_null' => true),
array('contactemail' , 'within' => array(5,255), 'allow_null' => true), //[email protected] ~ smallest possible email is 5 characters.
array('companyemail' , 'within' => array(5,255), 'allow_null' => true, 'allow_blank' => true), //[email protected] ~ smallest possible email is 5 characters.
array('companyname' , 'within' => array(1,75), 'allow_null' => true),
array('contactphonenumber' , 'within' => array(10,20), 'allow_null' => true),
array('companyphonenumber' , 'allow_null' => true, 'allow_blank' => true, 'within' => array(10,20)),
array('address' , 'within' => array(1,120))
);
對於companyphonenumber,我要的人物在10限制20,但我也希望讓那裏是空字符串或null如果輸入什麼。如果輸入了某些內容,則應該執行10至20個字符長的驗證檢查。
但這不起作用。 相反,當項目爲空或爲空時,內部驗證似乎仍會觸發。我做錯了什麼,或者PHPActiveRecord在這裏有bug?
嘗試刪除'allow_null'鍵嗎?這與空白不一樣嗎? – silkfire 2014-09-26 22:52:22