我将以下实体属性定义为以下元数据显示:
{"name":"website","dataType":"String",
"validators":[
{"name":"string"},
{"messageTemplate":"'%displayName%' is not valid",
"pattern":"^$|(^http|^https)://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/S*)?",
"name":"regExValidator"}]}
当我尝试调用entityAspect.validateProperty("website")
,并且website
属性的值为 null 时,对该validateProperty()
方法的调用会引发以下异常:
“无法获取未定义或空引用的属性‘complexAspect’”
我不会期望这种行为,因为website
实体属性可能为空。看起来该validateProperty
方法中可能存在空引用处理错误:
在Breeze.debug.js 中:
proto.validateProperty = function (property, context) {
var value = this.getPropertyValue(property); // performs validations
if (value.complexAspect) { // THROWS EXCEPTION IF 'value' IS NULL
return validateTarget(value);
}
context = context || {};
context.entity = this.entity;
if (typeof(property) === 'string') {
context.property = this.entity.entityType.getProperty(property, true);
context.propertyName = property;
} else {
context.property = property;
context.propertyName = property.name;
}
return this._validateProperty(value, context);
};
只是好奇我做错了什么,或者这只是一个错误?
谢谢,理查德