# Matcher

Represents a matcher that can perform special data matching capabilities between a given pattern and a target.

Extends: Matcher
Superclass of: Capture

- Source: [`assertions/lib/matcher.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/assertions/lib/matcher.ts#L7)

## Example

```ts
// Given a template -
// {
//   "Resources": {
//     "MyBar": {
//       "Type": "Foo::Bar",
//       "Properties": {
//         "Fred": {
//           "Wobble": ["Flob", "Flib"],
//         }
//       }
//     }
//   }
// }

// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
  Fred: {
    Wobble: [ Match.anyValue(), Match.anyValue() ],
  },
});

// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
  Fred: {
    Wimble: Match.anyValue(),
  },
});
```

## Initializer

```ts
new Matcher()
```

## Properties

- `name`: string — A name for the matcher.

  This is collected as part of the result and may be presented to the user.

## Methods

- `isMatcher(x: any): boolean` (static) — Check whether the provided object is a subtype of the `IMatcher`.

- `test(actual: any): MatchResult` — Test whether a target matches the provided pattern.

  Every Matcher must implement this method.
  This method will be invoked by the assertions framework. Do not call this method directly.

  **Parameters**

  - `actual` — the target to match.

  **Returns:** the list of match failures. An empty array denotes a successful match.
