Data asserts
<name> should be unique in the "<filepath>" file
Checks that the current value of a field (or aggregation of fields) is unique in a CSV or JSON input file
<name> should be unique in the "<filepath>" file
Where
<name>the name of the field (or comma separated fields aggregation) to check<filepath>the path to the CSV or JSON file
Examples
CSV Check
Given the CSV file: resources/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will check that all values in the Name column are unique:
Then Name should be unique in the "resources/StateCodes.csv" file
JSON Check
Given the JSON file: resources/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will check that all Name properties are unique:
Then Name should be unique in the "resources/StateCodes.json" file
<name> should be unique in <filepathRef file>
Checks that the current value of a field (or aggregation of fields) is unique in a CSV or JSON input file
<name> should be unique in <filepathRef file>
Where
<name>the name of the field (or comma separated fields aggregation) to check<filepathRef file>is the name of the binding containing the path of the CSV or JSON file
The data value contained in the first record that satisifes the given predicate will be bound to the global scope. Otherwise if no records match, then no value will be bound.
Examples
CSV Check
Given the CSV file: resources/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will check that all values in the Name column are unique:
Given the mapping file is "resources/StateCodes.csv"
Then Name should be unique in the mapping file
JSON Check
Given the JSON file: resources/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will check that all Name properties are unique:
Given the mapping file is "resources/StateCodes.json"
Then Name should be unique in the mapping file