Skip to content

Instantly share code, notes, and snippets.

@wojkos
Created November 14, 2018 09:57
Show Gist options
  • Save wojkos/c0d0034e37002ffbd0367df197bcb851 to your computer and use it in GitHub Desktop.
Save wojkos/c0d0034e37002ffbd0367df197bcb851 to your computer and use it in GitHub Desktop.
FarawayDistortedUsernames created by wojkos - https://repl.it/@wojkos/FarawayDistortedUsernames
text = {:user=>{:first_name=>["must be filled"], :email_address=>["Wrong email format"], :phone_number=>["Wrong phone number format. Use only digits with + on begining"], :address_attributes=>{:street=>["must be filled"], :city=>["must be filled"], :zip_code=>["Wrong zip code format. Use 00-000 format insted"], :country=>["Is not a correct country name"]}, :company_attributes=>{:address_attributes=>{:zip_code=>["Wrong zip code format. Use 00-000 format insted"], :country=>["Is not a correct country name"]}}}}
# def parse v
# if v.is_a?(Hash)
# v.each do |k, v|
# parse v
# p "#{k v}"
# end
# else
# v
# end
# end
def parse(k, v)
unless v.is_a?(Hash)
p "#{k} -> #{v}"
else
p k
p "-----"
v.each do |k, v|
parse(k, v)
end
end
end
text.each { |k, v| parse(k,v) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment