> Part of the walkerOS documentation. Project overview and full index: <https://www.walkeros.io/llms.txt>

# Mapping.Value

`Mapping.Value` is what you put into any mapping field that expects a value: `data`, every entry under `map`, entries in `set[]`, keys under `policy`, and anywhere a destination rule field accepts `any`. It is polymorphic: a value can be a simple string path, an object with one of several transforming keys, or an array of those. The shape is defined in [`packages/core/src/types/mapping.ts`](https://github.com/elbwalker/walkerOS/blob/main/packages/core/src/types/mapping.ts) as `Value = ValueType | Array<ValueType>`, where `ValueType` is either a string (path) or a `ValueConfig` object.

## Options[​](#options "Direct link to Options")

| Form                    | Shape                           | What / When                                                                                     |
| ----------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------- |
| [Path](#path)           | `string`                        | Reads a dot-path from the event. Use for copying raw fields straight into the output.           |
| [Constant](#constant)   | `{ value }`                     | Emits a fixed value. Use when the destination needs a literal like a currency, ID, or label.    |
| [Map](#map)             | `{ map: { key: Value, … } }`    | Builds an object from multiple paths. Use when the destination expects a structured payload.    |
| [Loop](#loop)           | `{ loop: [source, Value] }`     | Iterates an array source and transforms each item. Use for nested product, cart, or item lists. |
| [Set](#set)             | `{ set: [Value, Value, …] }`    | Picks the first defined value from a list. Use as a fallback chain like email then user\_id.    |
| [Fn](#fn)               | `{ fn: (value, context) => … }` | Runs a custom function on the event. Use only when no declarative form fits.                    |
| [Condition](#condition) | `{ condition, value }`          | Gates the value on a predicate. Use for branching logic inside a single rule.                   |
| [Consent](#consent)     | `{ consent: {…}, value }`       | Gates the value on consent states. Use to make individual fields privacy-aware.                 |

All `ValueConfig` keys can be combined on the same object: `key`, `condition`, `consent`, `validate` act as filters; `value`, `fn`, `map`, `loop`, `set` produce output.

## Path[​](#path "Direct link to Path")

Extract a value by dot-path from the event.

Configuration

Loading...

Result

Loading...

Paths also index into arrays:

Configuration

Loading...

Result

Loading...

## Constant[​](#constant "Direct link to Constant")

Return a fixed value, independent of the event.

Configuration

Loading...

Result

Loading...

## Map[​](#map "Direct link to Map")

Build an object by mapping keys to their own `Mapping.Value`.

Configuration

Loading...

Result

Loading...

## Loop[​](#loop "Direct link to Loop")

Iterate an array source and transform each element. `loop: [source, value]`: `source` selects the array (a path, or `'this'` for the event itself), `value` transforms each item.

Configuration

Loading...

Result

Loading...

## Set[​](#set "Direct link to Set")

Try each value in order and return the first defined result. Useful as a fallback chain.

```
{ set: ['data.email', 'user.email', { value: 'anonymous' }] }
```

## Fn[​](#fn "Direct link to Fn")

Run a custom function. The handler receives `(value, context)` and may return a promise. All three callbacks (`fn`, `condition`, `validate`) share the same shape.

### Context object[​](#context-object "Direct link to Context object")

| Field       | Type                            | Required | Description                                |
| ----------- | ------------------------------- | -------- | ------------------------------------------ |
| `event`     | `WalkerOS.DeepPartialEvent`     | yes      | The root event being mapped                |
| `mapping`   | `Mapping.Value \| Mapping.Rule` | yes      | The surrounding mapping config (or rule)   |
| `collector` | `Collector.Instance`            | yes      | Active collector, use for `push` and queue |
| `logger`    | `Logger.Instance`               | yes      | Use for `info`/`warn`/`error`/`debug`      |
| `consent`   | `WalkerOS.Consent` (optional)   | no       | Resolved consent at this evaluation point  |

One-arg callbacks like `(value) => value.toUpperCase()` continue to work, TypeScript ignores the unused `context` argument.

Configuration

Loading...

Result

Loading...

## Condition[​](#condition "Direct link to Condition")

Only produce output when `condition(event)` returns truthy.

```
{

  condition: (event) => event.data?.value > 50,

  value: 'high_value',

}
```

## Consent[​](#consent "Direct link to Consent")

Only produce output when the required consent states are granted on the event.

Configuration

Loading...

Result

Loading...

## Validate[​](#validate "Direct link to Validate")

`validate` is a filter, not a form. Combine it with any value-producing key. The function runs on the produced value; if it returns falsy the result is dropped (`undefined`).

Configuration

Loading...

Result

Loading...

## Policy[​](#policy "Direct link to Policy")

A policy is a record of `Mapping.Value`s applied to the event before the rule runs. The key is the path the result writes into; the value is any form above.

**Config-level policy** applies to every event handled by the source or destination:

```
{
  config: {
    policy: {
      'user.email': { fn: (e) => e.user?.email?.toLowerCase() },
      'data.timestamp': { fn: () => Date.now() },
    },
  },
}
```

**Event-level policy** applies only inside the matched rule:

```
{
  config: {
    mapping: {
      product: {
        view: {
          name: 'view_item',
          policy: {
            'data.id': { fn: (e) => `PRODUCT_${e.data?.id}` },
          },
        },
      },
    },
  },
}
```

Processing order: config policy → event matching → event policy → data transformation.

## See also[​](#see-also "Direct link to See also")

* [Mapping.Rule](https://www.walkeros.io/docs/mapping/rule.md): the rule object that composes values
* [`getMappingValue` API](https://www.walkeros.io/docs/mapping/rule.md#getmappingvalue): programmatic value resolution
* [Consent guide](https://www.walkeros.io/docs/guides/consent.md): consent model in depth
