diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/fields.ts b/packages/@aws-cdk/aws-stepfunctions/lib/fields.ts index 2d35536cf9172..8792fe02776ee 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/fields.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/fields.ts @@ -129,13 +129,13 @@ export class FieldUtils { } function validateDataPath(path: string) { - if (!path.startsWith('$.')) { - throw new Error("Data JSON path values must start with '$.'"); + if (path !== '$' && !path.startsWith('$.')) { + throw new Error("Data JSON path values must either be exactly equal to '$' or start with '$.'"); } } function validateContextPath(path: string) { - if (!path.startsWith('$$.')) { - throw new Error("Context JSON path values must start with '$$.'"); + if (path !== '$$' && !path.startsWith('$$.')) { + throw new Error("Context JSON path values must either be exactly equal to '$$' or start with '$$.'"); } } diff --git a/packages/@aws-cdk/aws-stepfunctions/test/test.fields.ts b/packages/@aws-cdk/aws-stepfunctions/test/test.fields.ts index 575b0d33d72e7..fdb41467815d5 100644 --- a/packages/@aws-cdk/aws-stepfunctions/test/test.fields.ts +++ b/packages/@aws-cdk/aws-stepfunctions/test/test.fields.ts @@ -80,17 +80,29 @@ export = { }, 'datafield path must be correct'(test: Test) { + test.ok(Data.stringAt('$')); + + test.throws(() => { + Data.stringAt('$hello'); + }, /exactly equal to '\$' or start with '\$.'/); + test.throws(() => { Data.stringAt('hello'); - }, /must start with '\$.'/); + }, /exactly equal to '\$' or start with '\$.'/); test.done(); }, 'context path must be correct'(test: Test) { + test.ok(Context.stringAt('$$')); + + test.throws(() => { + Context.stringAt('$$hello'); + }, /exactly equal to '\$\$' or start with '\$\$.'/); + test.throws(() => { Context.stringAt('hello'); - }, /must start with '\$\$.'/); + }, /exactly equal to '\$\$' or start with '\$\$.'/); test.done(); },