Skip to main content

pick

pick is a DTL operation that keeps only specific keys in a mapping and removes the rest.

Use it when a mapping should be reduced to an allowlist.

YOp

- pick:
path: user
keys: [name, email]

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to the mapping to filter.
keyssequence of stringsyesKeys to keep. Missing keys are ignored.

Behavior

  • Requires the target path to exist.
  • Requires the target to be a mapping.
  • Removes keys that are not listed.
  • Ignores listed keys that do not exist.

Errors

ErrorMeaning
PATH_NOT_FOUNDTarget path does not exist.
NOT_A_MAPPINGTarget is not a mapping.

Example

yops:
- pick:
path: config
keys: [host, port]

Input:

config:
host: localhost
port: 5432
secret: abc

Output:

config:
host: localhost
port: 5432