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

ruby-grape / grape / 25568438752 / 15
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/recompile-settings-mutation-race
DEFAULT BRANCH: master
Ran 08 May 2026 05:02PM UTC
Files 158
Run time 11s
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

08 May 2026 05:00PM UTC coverage: 95.623% (-0.007%) from 95.63%
25568438752.15

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)

1067 of 1177 branches covered (90.65%)

Branch coverage included in aggregate %.

3412 of 3507 relevant lines covered (97.29%)

1004.06 hits per line

Source Files on job run-3.4-Gemfile - 25568438752.15
  • 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 25568438752
  • 730a7f04 on github
  • Prev Job for on feature/hash-oneof-2385 (#25564552185.10)
  • Next Job for on feature/hash-oneof-2385 (#25571312409.10)
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