View Source SanitizeRecordsDocs (FatEcto v1.0.0)
This module sanitize the response by removing structs that are not loaded alognwith meta. It supports lists of maps, tuples and map.
use FatEcto.DataSanitizer, otp_app: :app_name, encoder_library: encode_library
Summary
Functions
Sanitizes the given record or list of records.
Functions
Sanitizes the given record or list of records.
Parameters
record/records
: A map, list of maps, or tuple.opts
: A keyword list of options::mask
: A list of keys whose values should be masked (e.g.,[card_number: "****"]
).:remove
: A list of keys to remove from the final result.:only
: A list of keys to include in the final result (all others are excluded).:except
: A list of keys to exclude from the final result.
Examples
iex> record = %{name: "John", card_number: "1234-5678-9012-3456", ssn: "123-45-6789"}
iex> sanitized = FatEcto.TestRecordUtils.sanitize(record, mask: [card_number: "****"], remove: [:ssn])
iex> sanitized
%{name: "John", card_number: "****"}