-
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.
Merge branch 'master' into add_pa114_to_new_validate
- Loading branch information
Showing
6 changed files
with
73 additions
and
4 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: Modified the RP102 validation to support the new validate format. The validation checks wether the id field equals the details field in an indicator type | ||
type: internal | ||
pr_number: 4355 |
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
34 changes: 34 additions & 0 deletions
34
demisto_sdk/commands/validate/validators/RP_validators/RP102_details_field_equals_id.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,34 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List | ||
|
||
from demisto_sdk.commands.common.constants import GitStatuses | ||
from demisto_sdk.commands.content_graph.objects.indicator_type import IndicatorType | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = IndicatorType | ||
|
||
|
||
class DetailsFieldEqualsIdValidator(BaseValidator[ContentTypes]): | ||
error_code = "RP102" | ||
description = "Validate that the id and the details fields are equal." | ||
error_message = "id and details fields are not equal. id={0}, details={1}" | ||
rationale = "To align with the platform requirements." | ||
related_field = "id" | ||
expected_git_statuses = [GitStatuses.ADDED] | ||
|
||
def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: | ||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format( | ||
content_item.object_id, content_item.description | ||
), | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if content_item.description != content_item.object_id | ||
] |