Skip to content

Commit

Permalink
chore: adding a new violation type Advance-Rules-Violation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayachand committed Sep 5, 2024
1 parent 1777c6c commit 5f2d074
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
23 changes: 23 additions & 0 deletions src/util/eventValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const violationTypes = {
AdditionalProperties: 'Additional-Properties',
UnknownViolation: 'Unknown-Violation',
UnplannedEvent: 'Unplanned-Event',
AdvanceRulesViolation: 'Advance-Rules-Violation',
};

const supportedEventTypes = {
Expand Down Expand Up @@ -227,6 +228,28 @@ async function validate(event) {
},
};
break;
case 'minLength':
case 'maxLength':
case 'pattern':

Check warning on line 233 in src/util/eventValidation.js

View check run for this annotation

Codecov / codecov/patch

src/util/eventValidation.js#L231-L233

Added lines #L231 - L233 were not covered by tests
case 'format':
case 'multipleOf':
case 'minimum':
case 'maximum':
case 'exclusiveMinimum':
case 'exclusiveMaximum':
case 'minItems':
case 'maxItems':
case 'uniqueItems':
case 'enum':
rudderValidationError = {
type: violationTypes.AdvanceRulesViolation,
message: error.message,
meta: {
instancePath: error.instancePath,
schemaPath: error.schemaPath,
},
};
break;
default:
rudderValidationError = {
type: violationTypes.UnknownViolation,
Expand Down
6 changes: 4 additions & 2 deletions test/__tests__/eventValidation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ const validationErrorsTestCases = [
validationErrors: [
{ type: "Datatype-Mismatch" },
{ type: "Unplanned-Event" },
{ type: "Additional-Properties" }
{ type: "Additional-Properties" },
{ type: "Advance-Rules-Violation" }
],
output: true
},
Expand All @@ -283,7 +284,8 @@ const validationErrorsTestCases = [
validationErrors: [
{ type: "Datatype-Mismatch" },
{ type: "Unplanned-Event" },
{ type: "Additional-Properties" }
{ type: "Additional-Properties" },
{ type: "Advance-Rules-Violation" }
],
output: true
},
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/trackingPlan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ const eventValidationTestCases = [
trackingPlan,
output: [
{
type: "Unknown-Violation",
type: "Advance-Rules-Violation",
message: "must be <= 4",
meta: {
instancePath: "/properties/revenue",
Expand Down Expand Up @@ -665,7 +665,7 @@ const eventValidationTestCases = [
instancePath: "/properties/dateString",
schemaPath: "#/properties/properties/properties/dateString/format",
},
type: "Unknown-Violation",
type: "Advance-Rules-Violation",
}
]
},
Expand Down

0 comments on commit 5f2d074

Please sign in to comment.