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

Support nested dependent parameters #1811

Merged
merged 2 commits into from
Nov 1, 2018

Commits on Nov 1, 2018

  1. Addes test in failing nested given validation

    andreacfm authored and Darren Chang committed Nov 1, 2018
    Configuration menu
    Copy the full SHA
    f2e0f3e View commit details
    Browse the repository at this point in the history
  2. Support nested dependent parameters

    `given` will check whether attribute is declared in its scope.
    If not, it raises an error.
    
    ```ruby
    optional :a
    given a: ->(val) { val == 'a' } do
      optional :b
      given b: ->(val) { val == 'b' } do
        requires :c
      end
    end
    ```
    
    In the example, `optional :a` creates a scope. `given a: ...` creates
    another scope, which parent scope is the one created by `optional :a`,
    and attributes `:b` declared in `optional :b` is pushed to parent scope.
    
    The bug here is `given b: ...` cannot find `:b` in its scope. Since the
    attribute `:b` is pushed to its parent scope. So, fix the code to
    check attribute in its parent scope if it has parent scope.
    Darren Chang committed Nov 1, 2018
    Configuration menu
    Copy the full SHA
    0b726dd View commit details
    Browse the repository at this point in the history