【问题标题】:Breeze property validation using data annotations in entity framework使用实体框架中的数据注释进行 Breeze 属性验证
【发布时间】:2013-10-30 01:17:06
【问题描述】:

在我的实体框架模型中,我有:

<Required(), Range(0, Double.MaxValue, ErrorMessage:="Weight must be numeric and cannot be negative")> _
Public Property Weight() As Double

<Required(), Range(0, Double.MaxValue, ErrorMessage:="Recycled content must be numeric and between 0 and 100")> _
Public Property RecycledContent() As Double

在我的视图模型中,我有:

        if (!editComponent().entityAspect.validateProperty("recycledContent")) {
            /* do something about errors */
            var msg = 'Recycled content is invalid!';
            logger.logError(msg, error, system.getModuleId(lt_articleEdit), true);
        }

然而,当我输入一个大于 100 的值(在回收的内容字段中)时,它仍然以某种方式通过了验证!我已经使用脚本调试器单步执行,在微风验证例程中注册了两个验证器,它们是“必需”和“数字”,但我看不到任何提及范围。

微风可以进行范围验证吗?我要做的就是根据模型的数据注释中的元数据提取数据验证错误,并使用它来触发错误字段上的客户端突出显示并记录错误消息。

【问题讨论】:

    标签: entity-framework data-annotations breeze


    【解决方案1】:

    这是一个非常合理的要求,但我们还没有做到。

    目前,Breeze 还没有从实体框架元数据中获取范围验证。请在Breeze User Voice 上为此投票。这很重要,因为我们确实根据这个地点优先考虑我们的工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多