0

我将以下实体属性定义为以下元数据显示:

{"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);
};

只是好奇我做错了什么,或者这只是一个错误?

谢谢,理查德

4

1 回答 1

0

编辑:这已在 Breeze v1.3.0 中修复,现在可用。


这是一个错误,将在本周晚些时候发布的下一个版本中修复。...感谢您找到并报告它:)

于 2013-04-15T17:14:16.433 回答