-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add change_message attribute to field content
- Loading branch information
Showing
4 changed files
with
159 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,36 @@ defmodule ExPass.Utils.Converter do | |
focusing on key format conversions. | ||
""" | ||
|
||
@doc """ | ||
Trims whitespace from string values in a map while preserving non-string values. | ||
This function iterates through the key-value pairs of the input map. For each pair, | ||
if the value is a string, it trims leading and trailing whitespace. Non-string | ||
values are left unchanged. | ||
## Parameters | ||
* `attrs` - A map containing key-value pairs to be processed. | ||
## Returns | ||
* A new map with the same keys as the input, but with string values trimmed. | ||
## Examples | ||
iex> attrs = %{name: " John Doe ", age: 30, email: " [email protected] "} | ||
iex> ExPass.Utils.Converter.trim_string_values(attrs) | ||
%{name: "John Doe", age: 30, email: "[email protected]"} | ||
""" | ||
@spec trim_string_values(map()) :: map() | ||
def trim_string_values(attrs) do | ||
Map.new(attrs, fn {key, value} -> | ||
trimmed_value = if is_binary(value), do: String.trim(value), else: value | ||
{key, trimmed_value} | ||
end) | ||
end | ||
|
||
@doc """ | ||
Converts a key (atom or string) to camelCase format. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters