Skip to content

Commit

Permalink
Merge pull request #68 from Cardano-Forge/refactor/fix-zod-error
Browse files Browse the repository at this point in the history
refactor: validationError to ZodIssue[]
  • Loading branch information
JFKFred authored Sep 26, 2024
2 parents 7eca236 + 61ec589 commit 606ddec
Show file tree
Hide file tree
Showing 25 changed files with 166 additions and 183 deletions.
12 changes: 6 additions & 6 deletions core/validator/__tests__/inputs/test.cetardio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,31 @@ Deno.test("TestCetardio", () => {
"key-lower-case"
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[0].validationError.issues.length,
result["CETARDIOwhitelist4"].warnings[0].validationErrors.length,
4
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[0].validationError.issues[0].path,
result["CETARDIOwhitelist4"].warnings[0].validationErrors[0].path,
["Discord"]
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[0].validationError.issues[1].path,
result["CETARDIOwhitelist4"].warnings[0].validationErrors[1].path,
["Twitter"]
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[0].validationError.issues[2].path,
result["CETARDIOwhitelist4"].warnings[0].validationErrors[2].path,
["Website"]
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[0].validationError.issues[3].path,
result["CETARDIOwhitelist4"].warnings[0].validationErrors[3].path,
["mediaType"]
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[1].validatorId,
"compare-attributes-keys"
);
assertEquals(
result["CETARDIOwhitelist4"].warnings[1].validationError.issues[0].message,
result["CETARDIOwhitelist4"].warnings[1].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);
});
18 changes: 9 additions & 9 deletions core/validator/__tests__/inputs/test.cornucopias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,34 @@ Deno.test("TestCornucopias", () => {
assertEquals(result["CFN00538"].warnings.length, 2);
assertEquals(result["CFN00538"].warnings[0].validatorId, "key-lower-case");

assertEquals(result["CFN00538"].warnings[0].validationError.issues.length, 7);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[0].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors.length, 7);
assertEquals(result["CFN00538"].warnings[0].validationErrors[0].path, [
"media",
"Website",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[1].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[1].path, [
"media",
"Link Tree",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[2].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[2].path, [
"fullName",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[3].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[3].path, [
"mediaType",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[4].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[4].path, [
"typeClass",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[5].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[5].path, [
"attributes",
"NodeType",
]);
assertEquals(result["CFN00538"].warnings[0].validationError.issues[6].path, [
assertEquals(result["CFN00538"].warnings[0].validationErrors[6].path, [
"projectName",
]);

assertEquals(result["CFN00538"].warnings[1].validatorId, "key-alphanumeric");
assertEquals(result["CFN00538"].warnings[1].validationError.issues[0].path, [
assertEquals(result["CFN00538"].warnings[1].validationErrors[0].path, [
"media",
"Link Tree",
]);
Expand Down
2 changes: 1 addition & 1 deletion core/validator/__tests__/inputs/test.deadpxlz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Deno.test("TestDeadpxlz", () => {
"compare-attributes-keys"
);
assertEquals(
result["PXL9951"].warnings[0].validationError.issues[0].message,
result["PXL9951"].warnings[0].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);
});
4 changes: 2 additions & 2 deletions core/validator/__tests__/inputs/test.earthnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Deno.test("TestEarthnode", () => {
"key-lower-case"
);
assertEquals(
result["EarthNode976"].warnings[0].validationError.issues[0].path,
result["EarthNode976"].warnings[0].validationErrors[0].path,
["mediaType"]
);

Expand All @@ -85,7 +85,7 @@ Deno.test("TestEarthnode", () => {
"compare-attributes-keys"
);
assertEquals(
result["EarthNode976"].warnings[1].validationError.issues[0].message,
result["EarthNode976"].warnings[1].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);
});
26 changes: 13 additions & 13 deletions core/validator/__tests__/inputs/test.kwic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ Deno.test("TestKwic", () => {
assertEquals(result["KWIC4479"].status, "warning");
assertEquals(result["KWIC4479"].warnings.length, 3);
assertEquals(result["KWIC4479"].warnings[0].validatorId, "key-lower-case");
assertEquals(result["KWIC4479"].warnings[0].validationError.issues.length, 9);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[0].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors.length, 9);
assertEquals(result["KWIC4479"].warnings[0].validationErrors[0].path, [
"Body",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[1].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[1].path, [
"Head",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[2].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[2].path, [
"Side",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[3].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[3].path, [
"Bling",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[4].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[4].path, [
"Faction",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[5].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[5].path, [
"Background",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[6].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[6].path, [
"Foreground",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[7].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[7].path, [
"Back Attachment",
]);
assertEquals(result["KWIC4479"].warnings[0].validationError.issues[8].path, [
assertEquals(result["KWIC4479"].warnings[0].validationErrors[8].path, [
"Head Attachment",
]);

Expand All @@ -106,15 +106,15 @@ Deno.test("TestKwic", () => {
"compare-attributes-keys"
);
assertEquals(
result["KWIC4479"].warnings[1].validationError.issues[0].message,
result["KWIC4479"].warnings[1].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);

assertEquals(result["KWIC4479"].warnings[2].validatorId, "key-alphanumeric");
assertEquals(result["KWIC4479"].warnings[2].validationError.issues[0].path, [
assertEquals(result["KWIC4479"].warnings[2].validationErrors[0].path, [
"Back Attachment",
]);
assertEquals(result["KWIC4479"].warnings[2].validationError.issues[1].path, [
assertEquals(result["KWIC4479"].warnings[2].validationErrors[1].path, [
"Head Attachment",
]);
});
34 changes: 17 additions & 17 deletions core/validator/__tests__/inputs/test.mogi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,35 @@ Deno.test("TestMogi", () => {
assertEquals(result["Mogi655"].status, "warning");
assertEquals(result["Mogi655"].warnings.length, 3);
assertEquals(result["Mogi655"].warnings[0].validatorId, "key-lower-case");
assertEquals(result["Mogi655"].warnings[0].validationError.issues.length, 10);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[0].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors.length, 10);
assertEquals(result["Mogi655"].warnings[0].validationErrors[0].path, [
"Bg",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[1].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[1].path, [
"Fur",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[2].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[2].path, [
"Hat",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[3].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[3].path, [
"Eyes",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[4].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[4].path, [
"Mouth",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[5].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[5].path, [
"Clothes",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[6].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[6].path, [
"Discord",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[7].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[7].path, [
"Twitter",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[8].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[8].path, [
"Weather",
]);
assertEquals(result["Mogi655"].warnings[0].validationError.issues[9].path, [
assertEquals(result["Mogi655"].warnings[0].validationErrors[9].path, [
"mediaType",
]);

Expand All @@ -111,21 +111,21 @@ Deno.test("TestMogi", () => {
"compare-attributes-keys"
);
assertEquals(
result["Mogi655"].warnings[1].validationError.issues[0].message,
result["Mogi655"].warnings[1].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);
assertEquals(result["Mogi655"].warnings[2].validatorId, "key-title-case");
assertEquals(result["Mogi655"].warnings[2].validationError.issues.length, 4);
assertEquals(result["Mogi655"].warnings[2].validationError.issues[0].path, [
assertEquals(result["Mogi655"].warnings[2].validationErrors.length, 4);
assertEquals(result["Mogi655"].warnings[2].validationErrors[0].path, [
"name",
]);
assertEquals(result["Mogi655"].warnings[2].validationError.issues[1].path, [
assertEquals(result["Mogi655"].warnings[2].validationErrors[1].path, [
"image",
]);
assertEquals(result["Mogi655"].warnings[2].validationError.issues[2].path, [
assertEquals(result["Mogi655"].warnings[2].validationErrors[2].path, [
"mediaType",
]);
assertEquals(result["Mogi655"].warnings[2].validationError.issues[3].path, [
assertEquals(result["Mogi655"].warnings[2].validationErrors[3].path, [
"description",
]);
});
18 changes: 9 additions & 9 deletions core/validator/__tests__/inputs/test.pavia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,27 @@ Deno.test("TestPavia", () => {
"key-lower-case"
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues.length,
result["PaviaEstate676"].warnings[0].validationErrors.length,
5
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues[0].path,
result["PaviaEstate676"].warnings[0].validationErrors[0].path,
["mediaType"]
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues[1].path,
result["PaviaEstate676"].warnings[0].validationErrors[1].path,
["estateSize"]
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues[2].path,
result["PaviaEstate676"].warnings[0].validationErrors[2].path,
["productInformation"]
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues[3].path,
result["PaviaEstate676"].warnings[0].validationErrors[3].path,
["productInformation", "Pavia io"]
);
assertEquals(
result["PaviaEstate676"].warnings[0].validationError.issues[4].path,
result["PaviaEstate676"].warnings[0].validationErrors[4].path,
["productInformation", "Copyright"]
);

Expand All @@ -105,19 +105,19 @@ Deno.test("TestPavia", () => {
"compare-attributes-keys"
);
assertEquals(
result["PaviaEstate676"].warnings[1].validationError.issues[0].message,
result["PaviaEstate676"].warnings[1].validationErrors[0].message,
"The `attributes` key might be missing from the supplied metadata, or an invalid threshold value may have been set."
);
assertEquals(
result["PaviaEstate676"].warnings[2].validatorId,
"key-alphanumeric"
);
assertEquals(
result["PaviaEstate676"].warnings[2].validationError.issues.length,
result["PaviaEstate676"].warnings[2].validationErrors.length,
1
);
assertEquals(
result["PaviaEstate676"].warnings[2].validationError.issues[0].path,
result["PaviaEstate676"].warnings[2].validationErrors[0].path,
["productInformation", "Pavia io"]
);
});
5 changes: 2 additions & 3 deletions core/validator/__tests__/test.attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ Deno.test("KeyAttributesValidator - withWarning", () => {
"key-attributes"
);
assertEquals(
result["NO_ASSET_NAME_PROVIDED"].warnings[0].validationError.issues[0]
.message,
result["NO_ASSET_NAME_PROVIDED"].warnings[0].validationErrors[0].message,
"It is recommended to use string instead of number"
);
assertEquals(
result["NO_ASSET_NAME_PROVIDED"].warnings[0].validationError.issues[0].path,
result["NO_ASSET_NAME_PROVIDED"].warnings[0].validationErrors[0].path,
["attributes", "number_field"]
);
});
Expand Down
Loading

0 comments on commit 606ddec

Please sign in to comment.