Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Nonstandard" array validation on conn validator #258

Open
marciotoze opened this issue Nov 21, 2020 · 0 comments
Open

"Nonstandard" array validation on conn validator #258

marciotoze opened this issue Nov 21, 2020 · 0 comments

Comments

@marciotoze
Copy link

Hi,

Is there some reason to validate array using comma separated pattern? Using query parameters like /api/post?tags[]=ab&tags[]=cd looks a better option since phoenix delivery this as array into controller.

defp validate_array(name, values, items=%{"type"=>type}, parameters) do
with :ok <- String.split(values, ",")
|> Enum.map(&{type, name, &1, false, Map.get(items, "enum"), nil})
|> validate_query_params()
do validate_query_params(parameters)
else
error -> error
end
end

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

No branches or pull requests

1 participant