Dataweave中的长度验证

时间:2015-10-16 11:11:16

标签: mule mule-studio mule-component mule-el dataweave

如何在Mule Dataweave中进行长度验证

%dw 1.0
%output application/xml
---
(payload default []) map {
    Field1:$.Field11,
    Field2:$.Field22,
    Field3:$.Field33,
    Field4:$.Field44
}

我想做max Length of Field22 < 20

之类的验证

如何在Mule Dataweave中实现这一目标

1 个答案:

答案 0 :(得分:2)

您可以使用sizeOf运算符在invidual字段上使用when条件:

%dw 1.0
%output application/xml
---
(payload default []) map {
    Field1:$.Field11,
    (Field2: $.Field22) when (sizeOf $.Field22) < 20,
      Field3:$.Field33,
    Field4:$.Field44
}