-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Combined MR101 and MR102 into the new validation format. Validates that the modeling rule yml file contains the schema and rules keys and that they are empty. | ||
type: internal | ||
pr_number: 4368 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
demisto_sdk/commands/validate/validators/MR_validators/MR101_validate_empty_keys.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List | ||
|
||
from demisto_sdk.commands.content_graph.objects.modeling_rule import ModelingRule | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = ModelingRule | ||
|
||
|
||
class ValidateEmptyKeysValidator(BaseValidator[ContentTypes]): | ||
error_code = "MR101" | ||
description = 'Validate that the modeling rules keys - "rules" and "schema" exist and are empty' | ||
rationale = "This validation is for compatibility resaons. Without those fields the modeling rules won't work." | ||
error_message = ( | ||
"Either the 'rules' key or the 'schema' key are missing or not empty, " | ||
"make sure to set the values of these keys to an empty string." | ||
) | ||
related_field = "modeling rule" | ||
|
||
def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: | ||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message, | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if content_item.schema_key != "" or content_item.rules_key != "" | ||
] |