• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 25609132258 / 31
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: refactor/de-morgan-conditions
DEFAULT BRANCH: master
Ran 09 May 2026 06:58PM UTC
Files 158
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 May 2026 06:53PM UTC coverage: 95.675% (-0.007%) from 95.682%
25609132258.31

Pull #2702

github

ericproulx
Add oneof: option for polymorphic Hash parameters

Resolves #2385. A Hash parameter can now declare multiple acceptable
shapes:

    params do
      requires :value, type: Hash, oneof: [
        proc { requires :fixed_price, type: Float },
        proc do
          requires :time_unit, type: String
          requires :rate, type: Float
        end
      ]
    end

At request time variants are tried in declaration order against a
deep-dup of the value; the first variant whose validators raise no
exceptions wins, and any coercions it performed are applied to the
parent params.

Each variant block runs in a real `ParamsScope` backed by a small
`OneofCollector` that captures validators locally instead of
registering them on the API. Because variants are evaluated through
the standard scope, the full params DSL is available inside —
`regexp:`, `values:`, `allow_blank:`, nested `Hash`/`Array`, and
so on all work without re-implementation. Variant validators are
themselves real frozen `Validators::Base` instances reused at
request time.

Definition-time guards: `oneof:` requires `type: Hash`, the array
must be non-empty, and every entry must be a `Proc`. Otherwise an
`ArgumentError` is raised at boot.

Adds `Grape::Validations::OneofCollector`,
`Grape::Validations::Validators::OneofValidator`, an `oneof` i18n
key, and `process_oneof!` in `ParamsScope#validates`. README and
CHANGELOG updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull Request #2702: Add oneof: option for polymorphic Hash parameters (#2385)

1070 of 1179 branches covered (90.75%)

Branch coverage included in aggregate %.

3421 of 3515 relevant lines covered (97.33%)

1007.7 hits per line

Source Files on job run-3.4-gemfiles/rack_3_0.gemfile - 25609132258.31
  • Tree
  • List 158
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 25609132258
  • 38f4ecdf on github
  • Prev Job for on feature/hash-oneof-2385 (#25608800647.16)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc