File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
packages/@aws-cdk/aws-stepfunctions Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,8 @@ enum CompoundOperator {
177
177
class VariableComparison extends Condition {
178
178
constructor ( private readonly variable : string , private readonly comparisonOperator : ComparisonOperator , private readonly value : any ) {
179
179
super ( ) ;
180
- if ( ! variable . startsWith ( '$.' ) ) {
181
- throw new Error ( `Variable reference must start with '$.', got '${ variable } '` ) ;
180
+ if ( ! / ^ \$ [ . [ ] / . test ( variable ) ) {
181
+ throw new Error ( `Variable reference must start with '$.' or '$[' , got '${ variable } '` ) ;
182
182
}
183
183
}
184
184
Original file line number Diff line number Diff line change @@ -2,13 +2,27 @@ import { Test } from 'nodeunit';
2
2
import stepfunctions = require( '../lib' ) ;
3
3
4
4
export = {
5
- 'Condition variables must start with $.' ( test : Test ) {
5
+ 'Condition variables must start with $. or $[ ' ( test : Test ) {
6
6
test . throws ( ( ) => {
7
7
stepfunctions . Condition . stringEquals ( 'a' , 'b' ) ;
8
8
} ) ;
9
9
10
10
test . done ( ) ;
11
11
} ,
12
+ 'Condition variables can start with $.' ( test : Test ) {
13
+ test . doesNotThrow ( ( ) => {
14
+ stepfunctions . Condition . stringEquals ( '$.a' , 'b' ) ;
15
+ } ) ;
16
+
17
+ test . done ( ) ;
18
+ } ,
19
+ 'Condition variables can start with $[' ( test : Test ) {
20
+ test . doesNotThrow ( ( ) => {
21
+ stepfunctions . Condition . stringEquals ( '$[0]' , 'a' ) ;
22
+ } ) ;
23
+
24
+ test . done ( ) ;
25
+ } ,
12
26
'NotConditon must render properly' ( test : Test ) {
13
27
assertRendersTo ( test ,
14
28
stepfunctions . Condition . not ( stepfunctions . Condition . stringEquals ( '$.a' , 'b' ) ) ,
You can’t perform that action at this time.
0 commit comments