WhereFieldEquals
Return all items from the list where their given 'field' attribute is equal to 'equalTo' argument E.g. !WhereFieldEquals with the following arguments: - value=[{ "name": "192.1,0.82", "type": "IP" }, { "name": "myFile.txt", "type": "File" }, { "name": "172.0.0.2", "type": "IP" }] - field='type' - equalTo='IP' - getField='name' Will return all items names where field 'type' equals 'IP' - ['192.1,0.82', '172.0.0.2'].
javascript · Filters And Transformers
Details
| ID | WhereFieldEquals |
|---|---|
| Language | javascript |
| From Version | 5.5.0 |
| Tags | transformer general entirelist |
README
Returns all items from the list where their given field attribute is equal to the equalTo argument.
For example, !WhereFieldEquals with the following arguments:
- value=[{ name: ‘192.1,0.82’, type: ‘IP’ }, { name: ‘myFile.txt, type: ‘File’ }, { name: ‘172.0.0.2’, type: ‘IP’ }]
- field=’type’
- equalTo=’IP’
- getField=’name’
This will return all item names where field type equals IP - [‘192.1,0.82’, ‘172.0.0.2’].
Script Data
| Name | Description |
|---|---|
| Script Type | javascript |
| Tags | transformer, general, entirelist |
Inputs
| Argument Name | Description |
|---|---|
| value | The list to apply the transformer to. |
| field | The attribute in the collection items to check equality against equalTo. |
| equalTo | The value to filter all items by in the collection. |
| getField | The field to extract from each item (Optional). |
| stringify | Whether the argument should be saved as a string (Optional). |
args: - default: true description: The list to apply the transformer to. name: value required: true isArray: true - description: The attribute in the collection items to check equality against `equalTo`. name: field required: true - description: The value to filter all items by in the collection. name: equalTo required: true - description: The field to extract from each item (Optional). name: getField predefined: - '' - name: stringify auto: PREDEFINED predefined: - "true" - "false" description: Whether the argument should be saved as a string (Optional). defaultValue: "true" comment: "Return all items from the list where their given 'field' attribute is equal to 'equalTo' argument\n\nE.g. !WhereFieldEquals with the following arguments:\n - value=[{ \"name\": \"192.1,0.82\", \"type\": \"IP\" }, { \"name\": \"myFile.txt\", \"type\": \"File\" }, { \"name\": \"172.0.0.2\", \"type\": \"IP\" }]\n - field='type'\n - equalTo='IP'\n - getField='name' \n\nWill return all items names where field 'type' equals 'IP' - ['192.1,0.82', '172.0.0.2']." commonfields: id: WhereFieldEquals version: -1 enabled: true name: WhereFieldEquals fromversion: 5.5.0 script: '-' tags: - transformer - general - entirelist timeout: '0' isllm: false type: javascript tests: - Email Address Enrichment - Generic v2.1 - Test - Test filters & transformers scripts