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

Add ArrayOf validator #444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ArrayOf validator #444

wants to merge 1 commit into from

Commits on Mar 17, 2016

  1. Add ArrayOf validator

    The intended usage
    
    ```ruby
    param :ids, ArrayOfValidator.for_class, of: Integer
    ```
    
    Explanation
    
    Instead of simply checking the value is an Integer, it will try to find
    a validator for that type.
    
    Motivation
    
    Rails of pass Integers as string. For example, instead of `ids: [1, 2]`
    it could be `ids: ["1", "2"]`. In this case, we would still think this
    is valid input.
    
    But if we do
    
    ```ruby
    param :ids, Array, of: Integer
    ```
    
    an error will be raised for `"1"` is not an number
    ywen committed Mar 17, 2016
    Configuration menu
    Copy the full SHA
    deb4ed1 View commit details
    Browse the repository at this point in the history