Skip to content

Atomize rule#30

Open
rakesh-voiger wants to merge 2 commits intoozziexsh:mainfrom
voigerio:atomize
Open

Atomize rule#30
rakesh-voiger wants to merge 2 commits intoozziexsh:mainfrom
voigerio:atomize

Conversation

@rakesh-voiger
Copy link

Allow map to auto convert keys passed as strings to atoms.

rules = [
  type: :map,
  atomize: true,
  map: %{
    :key => [type: :string]
  }
]

input = %{"key" => "value"}

assert Validate.validate(input, rules) == success(%{:key => "value"})
  • Converts only atom keys defined in the rules
  • No impact on the string keys defined in the rules
  • When both atom and string is present in the input, priority is given to atom key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant