File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -403,6 +403,78 @@ Here are common scenarios to best visualise how to use `fields`.
403403 }
404404 ```
405405
406+ === "All fields in an object"
407+
408+ You want to erase all values under `credentials` without listing each key individually.
409+
410+ > Expression: `masker.erase(data, { fields: ['credentials.*'] })`
411+
412+ === "Data"
413+
414+ ```json hl_lines="3-5"
415+ {
416+ "name": "Jane",
417+ "credentials": {
418+ "username": "admin",
419+ "password": "s3cret",
420+ "token": "abc123"
421+ }
422+ }
423+ ```
424+
425+ === "Result"
426+
427+ ```json hl_lines="3-5"
428+ {
429+ "name": "Jane",
430+ "credentials": {
431+ "username": "*****",
432+ "password": "*****",
433+ "token": "*****"
434+ }
435+ }
436+ ```
437+
438+ === "Nested field via object wildcard"
439+
440+ You want to erase the `ssn` field under every key in the `users` object.
441+
442+ > Expression: `masker.erase(data, { fields: ['users.*.ssn'] })`
443+
444+ === "Data"
445+
446+ ```json hl_lines="4 8"
447+ {
448+ "users": {
449+ "alice": {
450+ "ssn": "111-22-3333",
451+ "name": "Alice"
452+ },
453+ "bob": {
454+ "ssn": "444-55-6666",
455+ "name": "Bob"
456+ }
457+ }
458+ }
459+ ```
460+
461+ === "Result"
462+
463+ ```json hl_lines="4 8"
464+ {
465+ "users": {
466+ "alice": {
467+ "ssn": "*****",
468+ "name": "Alice"
469+ },
470+ "bob": {
471+ "ssn": "*****",
472+ "name": "Bob"
473+ }
474+ }
475+ }
476+ ```
477+
406478## Advanced
407479
408480### Using multiple keys
You can’t perform that action at this time.
0 commit comments