Contact Us 1-800-596-4880

isHandledBy

isHandledBy(base: MimeType, other: MimeType): Boolean

Returns true if the given MimeType value is handled by the base MimeType value.

Introduced in DataWeave version 2.7.0.

Parameters

Name Type Description

base

MimeType

The MIME type value used as baseline.

other

MimeType

The MIME type value to be validated.

Example

This example tests how MIME types handles several validations.

Source

%dw 2.0
import * from dw::module::Mime
output application/json

var JSON = {'type': "application", subtype: "json", parameters: {}}
var MULTIPART = {'type': "multipart", subtype: "form-data", parameters: {boundary: "my-boundary"}}
var ALL = {'type': "*", subtype: "*", parameters: {}}
---
{
  a: isHandledBy(JSON, JSON),
  b: isHandledBy({'type': "*", subtype: "json", parameters: {}}, JSON),
  c: isHandledBy({'type': "application", subtype: "*", parameters: {}}, JSON),
  d: isHandledBy(ALL, MULTIPART),
  e: isHandledBy(MULTIPART, ALL),
  f: isHandledBy(JSON, MULTIPART),
  g: isHandledBy(
    {'type': "application", subtype: "*+xml", parameters: {}},
    {'type': "application", subtype: "soap+xml", parameters: {}})
}

Output

{
  "a": true,
  "b": true,
  "c": true,
  "d": true,
  "e": false,
  "f": false,
  "g": true
}