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

Allow ArrayValidator to use other validators to validate array elements #626

Merged
merged 1 commit into from Jul 24, 2018
Merged

Allow ArrayValidator to use other validators to validate array elements #626

merged 1 commit into from Jul 24, 2018

Conversation

micapam
Copy link

@micapam micapam commented Jul 24, 2018

I had a situation where I needed to pass an array of integers in the query string.

I tried using array_of: Integer but this didn't work, because the values was passed in as an array of strings: ["1", "2"] instead of [1, 2].

This PR fixes that by allowing ArrayValidator to use other validators to validate the elements of the parameter array. So I was able to use array_of: :number. It should work for other validators too because it looks them up with BaseValidator.find.

I also added a spec.

@iNecas
Copy link
Member

iNecas commented Jul 24, 2018

Nice and simple. Thanks @micapam

@iNecas iNecas merged commit 0074284 into Apipie:master Jul 24, 2018
@iNecas
Copy link
Member

iNecas commented Jul 24, 2018

apipie-rails-0.5.10 is all yours :)

@micapam
Copy link
Author

micapam commented Jul 25, 2018

Cheers @iNecas !

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.

2 participants