# Condition

A Condition for use in a Choice state branch.

Obtainable from: Condition.and, Condition.booleanEquals, Condition.booleanEqualsJsonPath, Condition.isBoolean, Condition.isNotBoolean, Condition.isNotNull, Condition.isNotNumeric, Condition.isNotPresent, Condition.isNotString, Condition.isNotTimestamp, Condition.isNull, Condition.isNumeric, Condition.isPresent, Condition.isString, Condition.isTimestamp, Condition.jsonata, Condition.not, Condition.numberEquals, Condition.numberEqualsJsonPath, Condition.numberGreaterThan, Condition.numberGreaterThanEquals, Condition.numberGreaterThanEqualsJsonPath, Condition.numberGreaterThanJsonPath, Condition.numberLessThan, Condition.numberLessThanEquals, Condition.numberLessThanEqualsJsonPath, Condition.numberLessThanJsonPath, Condition.or, Condition.stringEquals, Condition.stringEqualsJsonPath, Condition.stringGreaterThan, Condition.stringGreaterThanEquals, Condition.stringGreaterThanEqualsJsonPath, Condition.stringGreaterThanJsonPath, Condition.stringLessThan, Condition.stringLessThanEquals, Condition.stringLessThanEqualsJsonPath, Condition.stringLessThanJsonPath, Condition.stringMatches, Condition.timestampEquals, Condition.timestampEqualsJsonPath, Condition.timestampGreaterThan, Condition.timestampGreaterThanEquals, Condition.timestampGreaterThanEqualsJsonPath, Condition.timestampGreaterThanJsonPath, Condition.timestampLessThan, Condition.timestampLessThanEquals, Condition.timestampLessThanEqualsJsonPath, Condition.timestampLessThanJsonPath
Used as argument in: [Choice.when](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Choice.html#when), Condition.and, Condition.not, Condition.or

- Source: [`aws-stepfunctions/lib/condition.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-stepfunctions/lib/condition.ts#L8)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
const map = new sfn.Map(this, 'Map State', {
  maxConcurrency: 1,
  itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
  itemSelector: {
    item: sfn.JsonPath.stringAt('$$.Map.Item.Value'),
  },
  resultPath: '$.mapOutput',
});

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
const choice = new sfn.Choice(this, 'Choice');
const condition1 = sfn.Condition.stringEquals('$.item.status', 'SUCCESS');
const step1 = new sfn.Pass(this, 'Step1');
const step2 = new sfn.Pass(this, 'Step2');
const finish = new sfn.Pass(this, 'Finish');

const definition = choice
    .when(condition1, step1)
    .otherwise(step2)
    .afterwards()
    .next(finish);

map.itemProcessor(definition);
```

Python:

```python
map = sfn.Map(self, "Map State",
    max_concurrency=1,
    items_path=sfn.JsonPath.string_at("$.inputForMap"),
    item_selector={
        "item": sfn.JsonPath.string_at("$.Map.Item.Value")
    },
    result_path="$.mapOutput"
)

# The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
# Below example is with a Choice and Pass step
choice = sfn.Choice(self, "Choice")
condition1 = sfn.Condition.string_equals("$.item.status", "SUCCESS")
step1 = sfn.Pass(self, "Step1")
step2 = sfn.Pass(self, "Step2")
finish = sfn.Pass(self, "Finish")

definition = choice.when(condition1, step1).otherwise(step2).afterwards().next(finish)

map.item_processor(definition)
```

Java:

```java
Map map = Map.Builder.create(this, "Map State")
        .maxConcurrency(1)
        .itemsPath(JsonPath.stringAt("$.inputForMap"))
        .itemSelector(Map.of(
                "item", JsonPath.stringAt("$.Map.Item.Value")))
        .resultPath("$.mapOutput")
        .build();

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
Choice choice = new Choice(this, "Choice");
Condition condition1 = Condition.stringEquals("$.item.status", "SUCCESS");
Pass step1 = new Pass(this, "Step1");
Pass step2 = new Pass(this, "Step2");
Pass finish = new Pass(this, "Finish");

Chain definition = choice.when(condition1, step1).otherwise(step2).afterwards().next(finish);

map.itemProcessor(definition);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var map = new Map(this, "Map State", new MapProps {
    MaxConcurrency = 1,
    ItemsPath = JsonPath.StringAt("$.inputForMap"),
    ItemSelector = new Dictionary<string, object> {
        { "item", JsonPath.StringAt("$.Map.Item.Value") }
    },
    ResultPath = "$.mapOutput"
});

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
var choice = new Choice(this, "Choice");
var condition1 = Condition.StringEquals("$.item.status", "SUCCESS");
var step1 = new Pass(this, "Step1");
var step2 = new Pass(this, "Step2");
var finish = new Pass(this, "Finish");

var definition = choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish);

map.ItemProcessor(definition);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
map := sfn.NewMap(this, jsii.String("Map State"), &MapProps{
	MaxConcurrency: jsii.Number(1),
	ItemsPath: sfn.JsonPath_StringAt(jsii.String("$.inputForMap")),
	ItemSelector: map[string]interface{}{
		"item": sfn.JsonPath_*StringAt(jsii.String("$.Map.Item.Value")),
	},
	ResultPath: jsii.String("$.mapOutput"),
})

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
choice := sfn.NewChoice(this, jsii.String("Choice"))
condition1 := sfn.Condition_StringEquals(jsii.String("$.item.status"), jsii.String("SUCCESS"))
step1 := sfn.NewPass(this, jsii.String("Step1"))
step2 := sfn.NewPass(this, jsii.String("Step2"))
finish := sfn.NewPass(this, jsii.String("Finish"))

definition := choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish)

map.ItemProcessor(definition)
```

## Initializer

TypeScript:

```ts
new Condition()
```

Python:

```python
Condition()
```

Java:

```java
new Condition()
```

C# / .NET:

```csharp
new Condition()
```

Golang:

```go
NewCondition()
```

## Methods

- `and(...conditions: Condition[]): Condition // chainable` (static) — Combine two or more conditions with a logical AND.

- `booleanEquals(variable: string, value: boolean): Condition // chainable` (static) — Matches if a boolean field has the given value.

- `booleanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a boolean field equals to a value at a given mapping path.

- `isBoolean(variable: string): Condition // chainable` (static) — Matches if variable is boolean.

- `isNotBoolean(variable: string): Condition // chainable` (static) — Matches if variable is not boolean.

- `isNotNull(variable: string): Condition // chainable` (static) — Matches if variable is not null.

- `isNotNumeric(variable: string): Condition // chainable` (static) — Matches if variable is not numeric.

- `isNotPresent(variable: string): Condition // chainable` (static) — Matches if variable is not present.

- `isNotString(variable: string): Condition // chainable` (static) — Matches if variable is not a string.

- `isNotTimestamp(variable: string): Condition // chainable` (static) — Matches if variable is not a timestamp.

- `isNull(variable: string): Condition // chainable` (static) — Matches if variable is Null.

- `isNumeric(variable: string): Condition // chainable` (static) — Matches if variable is numeric.

- `isPresent(variable: string): Condition // chainable` (static) — Matches if variable is present.

- `isString(variable: string): Condition // chainable` (static) — Matches if variable is a string.

- `isTimestamp(variable: string): Condition // chainable` (static) — Matches if variable is a timestamp.

- `jsonata(condition: string): Condition // chainable` (static) — JSONata expression condition.

- `not(condition: Condition): Condition // chainable` (static) — Negate a condition.

- `numberEquals(variable: string, value: number): Condition // chainable` (static) — Matches if a numeric field has the given value.

- `numberEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a numeric field has the value in a given mapping path.

- `numberGreaterThan(variable: string, value: number): Condition // chainable` (static) — Matches if a numeric field is greater than the given value.

- `numberGreaterThanEquals(variable: string, value: number): Condition // chainable` (static) — Matches if a numeric field is greater than or equal to the given value.

- `numberGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a numeric field is greater than or equal to the value at a given mapping path.

- `numberGreaterThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a numeric field is greater than the value at a given mapping path.

- `numberLessThan(variable: string, value: number): Condition // chainable` (static) — Matches if a numeric field is less than the given value.

- `numberLessThanEquals(variable: string, value: number): Condition // chainable` (static) — Matches if a numeric field is less than or equal to the given value.

- `numberLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a numeric field is less than or equal to the numeric value at given mapping path.

- `numberLessThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a numeric field is less than the value at the given mapping path.

- `or(...conditions: Condition[]): Condition // chainable` (static) — Combine two or more conditions with a logical OR.

- `renderCondition(): any` — Render Amazon States Language JSON for the condition.

- `stringEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a string field has the given value.

- `stringEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a string field equals to a value at a given mapping path.

- `stringGreaterThan(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts after a given value.

- `stringGreaterThanEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts after or equal to a given value.

- `stringGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts after or equal to value at a given mapping path.

- `stringGreaterThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts after a value at a given mapping path.

- `stringLessThan(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts before a given value.

- `stringLessThanEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts equal to or before a given value.

- `stringLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts equal to or before a given mapping.

- `stringLessThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a string field sorts before a given value at a particular mapping.

- `stringMatches(variable: string, value: string): Condition // chainable` (static) — Matches if a field matches a string pattern that can contain a wild card (*) e.g: log-*.txt or *LATEST*. No other characters other than "*" have any special meaning - * can be escaped: \\*.

- `timestampEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is the same time as the given timestamp.

- `timestampEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is the same time as the timestamp at a given mapping path.

- `timestampGreaterThan(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is after the given timestamp.

- `timestampGreaterThanEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is after or equal to the given timestamp.

- `timestampGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is after or equal to the timestamp at a given mapping path.

- `timestampGreaterThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is after the timestamp at a given mapping path.

- `timestampLessThan(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is before the given timestamp.

- `timestampLessThanEquals(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is before or equal to the given timestamp.

- `timestampLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is before or equal to the timestamp at a given mapping path.

- `timestampLessThanJsonPath(variable: string, value: string): Condition // chainable` (static) — Matches if a timestamp field is before the timestamp at a given mapping path.
