Skip to content

Commit

Permalink
Reject keys starting with digits
Browse files Browse the repository at this point in the history
  • Loading branch information
LcTwisk committed Nov 3, 2021
1 parent e239c6d commit f6f8238
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"^COPY$": {
"$ref": "#/definitions/TranslationWrapper"
},
"^(?!COPY|ACCESSIBILITY).*$": {
"^(?!COPY|ACCESSIBILITY)\\D.*$": {
"$ref": "#/definitions/Node"
}
},
Expand Down
7 changes: 7 additions & 0 deletions tests/actions/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ test("validating fails when there's a collection requested that doesn't exist in
);
expect(res.isError).toBe(true);
});

test("validating fails when there's a key that starts with a digit", () => {
const res = loadYaml("tests/input/localicipe_invalid_key.yaml").flatMap(data =>
validate(data, ["en"], undefined, ["COLLECTION"])
);
expect(res.isError).toBe(true);
});
7 changes: 7 additions & 0 deletions tests/input/localicipe_invalid_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
COLLECTION:
Checkout:
1KeyStartingWithADigit:
Total:
COPY:
en: 'This is copy'

0 comments on commit f6f8238

Please sign in to comment.