This module enables you to perform type introspection.
To use this module, you must import it to your DataWeave code, for example,
by adding the line import * from dw::core::Types
to the header of your
DataWeave script.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Functions
arrayItem
arrayItem(Type): Type
Returns the type of the given array. This function fails if the input is not an Array type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how arrayItem
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
%dw 2.0
import * from dw::core::Types
type ArrayOfString = Array<String>
type ArrayOfNumber = Array<Number>
type ArrayOfAny = Array<Any>
type ArrayOfAnyDefault = Array
output application/json
---
{
a: arrayItem(ArrayOfString),
b: arrayItem(ArrayOfNumber),
c: arrayItem(ArrayOfAny),
d: arrayItem(ArrayOfAnyDefault)
}
Output
1
2
3
4
5
6
{
"a": "String",
"b": "Number",
"c": "Any",
"d": "Any"
}
baseTypeOf
baseTypeOf(Type): Type
Returns an the base type of the given type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how baseTypeOf
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
%dw 2.0
import * from dw::core::Types
type AType = String {format: "YYYY-MM-dd"}
output application/json
---
{
a: baseTypeOf(AType)
}
Output
1
2
3
{
"a": "String"
}
functionParamTypes
functionParamTypes(Type): Array<FunctionParam>
Returns the list of parameters from the given function type. This function fails if the provided type is not a Function type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The function type. |
Example
This example shows how functionParamTypes
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
import * from dw::core::Types
type AFunction = (String, Number) -> Number
type AFunction2 = () -> Number
---
{
a: functionParamTypes(AFunction),
b: functionParamTypes(AFunction2)
}
Output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"a": [
{
"paramType": "String",
"optional": false
},
{
"paramType": "Number",
"optional": false
}
],
"b": [
]
}
functionReturnType
functionReturnType(Type): Type | Null
Returns the type of a function’s return type. This function fails if the input type is not a Function type.
_Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later._
Parameters
Name | Description |
---|---|
t |
The function type. |
Example
This example shows how functionReturnType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
import * from dw::core::Types
type AFunction = (String, Number) -> Number
type AFunction2 = () -> Number
---
{
a: functionReturnType(AFunction),
b: functionReturnType(AFunction2)
}
Output
1
2
3
4
{
"a": "Number",
"b": "Number"
}
intersectionItems
intersectionItems(Type): Array<Type>
Returns an array of all the types that define a given Intersection type. This function fails if the input is not an Intersection type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how intersectionItems
behaves with different inputs.
Note that the AType
variable defines an Intersection type
{name: String} & {age: Number}
by using an &
between
the two objects.
Source
1
2
3
4
5
6
7
8
%dw 2.0
import * from dw::core::Types
type AType = {name: String} & {age: Number}
output application/json
---
{
a: intersectionItems(AType)
}
Output
1
2
3
{
"a": ["Object","Object"]
}
isAnyType
isAnyType(Type): Boolean
Returns true
if the input is the Any type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isAnyType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type AAny = Any
output application/json
---
{
a: isAnyType(AAny),
b: isAnyType(Any),
c: isAnyType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isArrayType
isArrayType(Type): Boolean
Returns true
if the input type is the Array type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isArrayType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type AType = Array<String>
output application/json
---
{
a: isArrayType(AType),
b: isArrayType(Boolean),
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isBinaryType
isBinaryType(Type): Boolean
Returns true
if the input is the Binary type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isBinaryType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ABinary = Binary
output application/json
---
{
a: isBinaryType(ABinary),
b: isBinaryType(Binary),
c: isBinaryType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isBooleanType
isBooleanType(Type): Boolean
Returns true
if the input is the Boolean type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isBooleanType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ABoolean = Boolean
output application/json
---
{
a: isBooleanType(ABoolean),
b: isBooleanType(Boolean),
c: isBooleanType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isDateTimeType
isDateTimeType(Type): Boolean
Returns true
if the input is the DateTime type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isDateTimeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ADateTime = DateTime
output application/json
---
{
a: isDateTimeType(ADateTime),
b: isDateTimeType(DateTime),
c: isDateTimeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isDateType
isDateType(Type): Boolean
Returns true
if the input is the Date type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isDateType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ADate = Date
output application/json
---
{
a: isDateType(ADate),
b: isDateType(Date),
c: isDateType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isFunctionType
isFunctionType(Type): Boolean
Returns true
if the input is the Function type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isFunctionType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type AFunction = (String) -> String
output application/json
---
{
a: isFunctionType(AFunction),
b: isFunctionType(Boolean)
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isIntersectionType
isIntersectionType(Type): Boolean
Returns true
if the input type is the Intersection type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isIntersectionType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type AType = {name: String} & {age: Number}
output application/json
---
{
a: isIntersectionType(AType),
b: isIntersectionType(Boolean),
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isKeyType
isKeyType(Type): Boolean
Returns true
if the input is the Key type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isKeyType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type AKey = Key
output application/json
---
{
a: isKeyType(AKey),
b: isKeyType(Key),
c: isKeyType(Boolean),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isLiteralType
isLiteralType(Type): Boolean
Returns true
if the input is the Literal type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isLiteralType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type ALiteralType = "Mariano"
output application/json
---
{
a: isLiteralType(ALiteralType),
b: isLiteralType(Boolean)
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isLocalDateTimeType
isLocalDateTimeType(Type): Boolean
Returns true
if the input is the LocalDateTime type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isLocalDateTimeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ALocalDateTime = LocalDateTime
output application/json
---
{
a: isLocalDateTimeType(ALocalDateTime),
b: isLocalDateTimeType(LocalDateTime),
c: isLocalDateTimeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isLocalTimeType
isLocalTimeType(Type): Boolean
Returns true
if the input is the LocalTime type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isLocalTimeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ALocalTime = LocalTime
output application/json
---
{
a: isLocalTimeType(ALocalTime),
b: isLocalTimeType(LocalTime),
c: isLocalTimeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isNamespaceType
isNamespaceType(Type): Boolean
Returns true
if the input is the Namespace type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isNamespaceType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ANamespace = Namespace
output application/json
---
{
a: isNamespaceType(ANamespace),
b: isNamespaceType(Namespace),
c: isNamespaceType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isNothingType
isNothingType(Type): Boolean
Returns true
if the input is the Nothing type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isNothingType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ANothing = Nothing
output application/json
---
{
a: isNothingType(ANothing),
b: isNothingType(Nothing),
c: isNothingType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isNullType
isNullType(Type): Boolean
Returns true
if the input is the Null type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isNullType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ANull = Null
output application/json
---
{
a: isNullType(ANull),
b: isNullType(Null),
c: isNullType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isNumberType
isNumberType(Type): Boolean
Returns true
if the input is the Number type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isNumberType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ANumber = Number
output application/json
---
{
a: isNumberType(ANumber),
b: isNumberType(Number),
c: isNumberType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isObjectType
isObjectType(Type): Boolean
Returns true
if the input is the Object type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isObjectType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type AType = {name: String}
output application/json
---
{
a: isObjectType(AType),
b: isObjectType(Boolean),
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isPeriodType
isPeriodType(Type): Boolean
Returns true
if the input is the Period type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isPeriodType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type APeriod = Period
output application/json
---
{
a: isPeriodType(APeriod),
b: isPeriodType(Period),
c: isPeriodType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isRangeType
isRangeType(Type): Boolean
Returns true
if the input is the Range type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isRangeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ARange = Range
output application/json
---
{
a: isRangeType(ARange),
b: isRangeType(Range),
c: isRangeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isReferenceType
isReferenceType(Type): Boolean
Returns true
if the input type is a Reference type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isReferenceType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
11
%dw 2.0
output application/json
import * from dw::core::Types
type AArray = Array<String> {n: 1}
type AArray2 = Array<AArray>
---
{
a: isReferenceType( AArray),
b: isReferenceType(arrayItem(AArray2)),
c: isReferenceType(String)
}
Output
1
2
3
4
5
{
"a": false,
"b": true,
"c": false
}
isRegexType
isRegexType(Type): Boolean
Returns true
if the input is the Regex type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isRegexType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ARegex = Regex
output application/json
---
{
a: isRegexType(ARegex),
b: isRegexType(Regex),
c: isRegexType(Boolean),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isStringType
isStringType(Type): Boolean
Returns true
if the input is the String type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isStringType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type AString = String
output application/json
---
{
a: isStringType(AString),
b: isStringType(String),
c: isStringType(Boolean),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isTimeType
isTimeType(Type): Boolean
Returns true
if the input is the Time type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isTimeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ATime = Time
output application/json
---
{
a: isTimeType(ATime),
b: isTimeType(Time),
c: isTimeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isTimeZoneType
isTimeZoneType(Type): Boolean
Returns true
if the input is the TimeZone type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isTimeZoneType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type ATimeZone = TimeZone
output application/json
---
{
a: isTimeZoneType(ATimeZone),
b: isTimeZoneType(TimeZone),
c: isTimeZoneType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isTypeType
isTypeType(Type): Boolean
Returns true
if the input is the Type type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isTypeType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type AType = Type
output application/json
---
{
a: isTypeType(AType),
b: isTypeType(Type),
c: isTypeType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
isUnionType
isUnionType(Type): Boolean
Returns true
if the input type is the Union type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isUnionType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::core::Types
type AType = String | Number
output application/json
---
{
a: isUnionType(AType),
b: isUnionType(Boolean),
}
Output
1
2
3
4
{
"a": true,
"b": false
}
isUriType
isUriType(Type): Boolean
Returns true
if the input is the Uri type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how isUriType
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
import * from dw::core::Types
type AUri = Uri
output application/json
---
{
a: isUriType(AUri),
b: isUriType(Uri),
c: isUriType(String),
}
Output
1
2
3
4
5
{
"a": true,
"b": true,
"c": false
}
literalValueOf
literalValueOf(Type): String | Number | Boolean
Returns the value of an input belongs to the Literal type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how literalValueOf
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
%dw 2.0
import * from dw::core::Types
type AType = "Mariano"
output application/json
---
{
a: literalValueOf(AType)
}
Output
1
2
3
{
"a": "Mariano"
}
metadataOf
metadataOf(Type): Object
Returns metadata that is attached to the given type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to check. |
Example
This example shows how metadataOf
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
%dw 2.0
import * from dw::core::Types
type AType = String {format: "YYYY-MM-dd"}
output application/json
---
{
a: metadataOf(AType)
}
Output
1
2
3
{
"a": {"format": "YYYY-MM-dd"}
}
nameOf
nameOf(Type): String
Returns the name of the input type.
Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.
Parameters
Name | Description |
---|---|
t |
The type to query |
Example
This example shows how nameOf
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
11
%dw 2.0
output application/json
import * from dw::core::Types
type AArray = Array<String> {n: 1}
type AArray2 = Array<String>
---
{
a: nameOf(AArray),
b: nameOf(AArray2),
c: nameOf(String)
}
Output
1
2
3
4
5
{
"a": "AArray",
"b": "AArray2",
"c": "String"
}
objectFields
objectFields(Type): Array<Field>
Returns the array of fields from the given Object type. This function fails if the type is not an Object type.
_Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later._
Parameters
Name | Description |
---|---|
t |
The function type. |
Example
This example shows how objectFields
behaves with different inputs.
Source
1
2
3
4
5
6
7
8
9
10
11
12
import * from dw::core::Types
ns ns0 http://acme.com
type ADictionary = {_ : String}
type ASchema = {ns0#name @(ns0#foo: String): {}}
type AUser = {name @(foo?: String,l: Number)?: String, lastName*: Number}
---
{
a: objectFields(ADictionary),
b: objectFields(ASchema),
c: objectFields(Object),
d: objectFields(AUser)
}
Output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
"a": [
{
"key": {
"name": {
"localName": "_",
"namespace": null
},
"attributes": [
]
},
"required": true,
"repeated": false,
"value": "String"
}
],
"b": [
{
"key": {
"name": {
"localName": "name",
"namespace": "http://acme.com"
},
"attributes": [
{
"name": {
"localName": "foo",
"namespace": "http://acme.com"
},
"value": "String",
"required": true
}
]
},
"required": true,
"repeated": false,
"value": "Object"
}
],
"c": [
],
"d": [
{
"key": {
"name": {
"localName": "name",
"namespace": null
},
"attributes": [
{
"name": {
"localName": "foo",
"namespace": null
},
"value": "String",
"required": false
},
{
"name": {
"localName": "l",
"namespace": null
},
"value": "Number",
"required": true
}
]
},
"required": false,
"repeated": false,
"value": "String"
},
{
"key": {
"name": {
"localName": "lastName",
"namespace": null
},
"attributes": [
]
},
"required": true,
"repeated": true,
"value": "Number"
}
]
}
* ----
=== unionItems
==== unionItems(Type): Array<Type>
Returns an array of all the types that define a given Union type.
This function fails if the input is not a Union type.
_Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later._
===== Parameters
[%header, cols="1,3"]
|===
| Name | Description
| t | The type to check.
|===
===== Example
This example shows how `unionItems` behaves with different inputs.
====== Source
[source,DataWeave,linenums]
%dw 2.0 import * from dw::core::Types type AType = String | Number output application/json --- { a: unionItems(AType) }
====== Output [source,Json,linenums]
{ "a": ["String","Number"] }
== Types === Attribute Represents an Attribute definition that is part of an Object field Key. .Definition [source,DataWeave,linenums]
{ name: QName, required: Boolean, value: Type }
=== Field Represents a Field description that is part of an Object. .Definition [source,DataWeave,linenums]
{ key: { name: QName, attributes: Array<Attribute> }, required: Boolean, repeated: Boolean, value: Type }
=== FunctionParam Represents a Function parameter that is part of a Function type. .Definition [source,DataWeave,linenums]
{ paramType: Type, optional: Boolean }
=== QName Represents a Qualified Name definition with a `localName` (a string) and a `namespace`. If the QName does not have a Namespace, its value is `null`. .Definition [source,DataWeave,linenums]
{ localName: String, namespace: Namespace | Null }