【问题标题】:Codeeffect Rule Engine - How to define rules to check length of stringCodeeffects 规则引擎 - 如何定义规则来检查字符串的长度
【发布时间】:2017-10-23 22:57:39
【问题描述】:

我必须定义一个规则,例如 长度为 5 且不等于“N/A”。

我无法在字符串数据类型的运算符列表中获取 Len() 函数。

如果需要定义任何字段级属性,请提出建议。

【问题讨论】:

    标签: rule-engine business-rules codeeffects


    【解决方案1】:

    在你的源类中定义一个这样的方法:

    public int Length(string str)
    {
       return string.IsNullOrEmpty(str) ? 0 : str.Length;
    }
    

    然后运行您的项目,打开规则编辑器并像这样创建您的规则:

    Check if YourString has any value and Length(YourString) is greater than [5]
    

    规则内方法详情可以found here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多