VerifyObjectFieldsList
Verifies that a given object includes all the given fields.
python · Developer Tools
Details
| ID | VerifyObjectFieldsList |
|---|---|
| Language | python |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Tags | basescript |
README
Verifies that a given object includes all the given fields.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | basescript |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| fields_to_search | Fields to search if they exist in map. |
| object | Map in which to search fields. |
Outputs
| Path | Description | Type |
|---|---|---|
| FieldsExists | If true, all the given fields exist in the object. | boolean |
Script Example
!VerifyObjectFieldsList fields_to_search=name,type object=${Indicators}
Context Example
{
"CheckIfFieldsExists": {
"FieldsExists": true
}
}
Human Readable Output
Results
Fields name, type are in given context.
import pytest from VerifyObjectFieldsList import check_fields CONTEXT1 = {"FirstField": {"SecondField": {"ThirdField": 1}}} CONTEXT2 = {"FirstField": [{"SecondField": [{"ThirdField": 1, "FourthField": 3}, {"ThirdField": 2, "FourthField": 4}]}]} @pytest.mark.parametrize( "fields_to_search,context,expected_result", [ ("FirstField.SecondField.ThirdField", CONTEXT1, (True, None)), ("FirstField.SecondField.FiveField", CONTEXT1, (False, "FirstField.SecondField.FiveField")), ("FirstField.SecondField.ThirdField", CONTEXT2, (True, None)), ("FirstField.SecondField.FourthField", CONTEXT2, (True, None)), ("FirstField.FiveField", CONTEXT2, (False, "FirstField.FiveField")), ], ) def test_check_fields(fields_to_search, context, expected_result): fields = fields_to_search.split(",") assert check_fields(fields, context) == expected_result