我正在使用学说并尝试验证一些模型。
我的 YAML 架构中有以下内容:
User:
package: User
columns:
username:
type: string
notnull: true
notblank: true
minlength: 4
password:
type: string
notnull: true
如果我创建一个新用户,它总是验证,不管我给它什么值。
例如:
$testuser = new User();
$testuser->username = ' ';
if ( ! $testuser->isValid())
{
echo 'User is invalid!';
}
编辑:以上只是一个例子。即使模式中指定为 NOT NULL 的值被省略,它仍然会验证。
永远不会产生无效的方法。有谁知道这可能是什么原因造成的?任何建议表示赞赏。谢谢。