可选字段的验证规则

Validation rules for optional fields

如何使用 Orbeon 表单生成器创建的输入字段是可选的,但仍然有验证规则? 一旦我添加验证规则,该字段就无效,即使我将它设置为可选(不是必需的)。

应为空或介于 0 和 100 之间的数字示例:

<fr:number id="control-1-control" bind="control-1-bind"></fr:number>

有了这个绑定:

<xf:bind id="control-1-bind" ref="control-1" name="control-1"
    type="xf:decimal" constraint=". ge 0 and . le 100"/>
</xf:bind>

我怎样才能明确地将其设为可选?我尝试将约束更改为 . eq '' or . ge 0 and . le 100 但这不起作用...我该怎么做才能允许空值?

我同意:所有可选字段和空字段在所有情况下都始终有效是有意义的。但是,在 XForms spec, this isn't the case right now. This being said, we have an RFE for doing this by default in the context of forms created by Form Builder.

之后

现在你可以自己做,作为约束的一部分,通过添加:

xxf:trim() = '' or (. ge 0 and . le 100)