> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrics-man.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Clamp

# \$clamp

The `$clamp` operator constrains a value within minimum and maximum bounds.

## Input

* An array containing exactly three numeric values: the value to clamp, the minimum bound, and the maximum bound

## Output

* The clamped value within the specified bounds

## Examples

### Clamp Value Within Range

```json theme={null}
{
  "$clamp": [
    15,
    0,
    10
  ]
}
```

Result: `10` (since 15 is above the max of 10, it gets clamped to 10)

### Clamp Value Below Range

```json theme={null}
{
  "$clamp": [
    -5,
    0,
    10
  ]
}
```

Result: `0` (since -5 is below the min of 0, it gets clamped to 0)

### Value Within Range

```json theme={null}
{
  "$clamp": [
    5,
    0,
    10
  ]
}
```

Result: `5` (since 5 is within the range, it remains unchanged)

### From Fields

```json theme={null}
{
  "$clamp": [
    {
      "$input": "value"
    },
    {
      "$input": "min"
    },
    {
      "$input": "max"
    }
  ]
}
```

Result: The value field clamped between the min and max field values
