How to do length validation in Mule Dataweave
%dw 1.0
%output application/xml
---
(payload default []) map {
Field1:$.Field11,
Field2:$.Field22,
Field3:$.Field33,
Field4:$.Field44
}
I want to do validation like max Length of Field22 < 20
How to achieve this in Mule Dataweave
You can use a when condition on an invidual field using the sizeOf operator:
%dw 1.0
%output application/xml
---
(payload default []) map {
Field1:$.Field11,
(Field2: $.Field22) when (sizeOf $.Field22) < 20,
Field3:$.Field33,
Field4:$.Field44
}