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

ruby-grape / grape / 25873175083 / 24
97%
master: 97%

Build:
DEFAULT BRANCH: master
Ran 14 May 2026 04:54PM UTC
Files 160
Run time 8s
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

14 May 2026 04:53PM UTC coverage: 95.795% (+0.01%) from 95.783%
25873175083.24

push

github

web-flow
Add oneof: option for polymorphic Hash parameters (#2702)

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>

1062 of 1169 branches covered (90.85%)

Branch coverage included in aggregate %.

3472 of 3564 relevant lines covered (97.42%)

1000.62 hits per line

Source Files on job run-3.2-gemfiles/rack_3_2.gemfile - 25873175083.24
  • Tree
  • List 160
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 25873175083
  • 7aeedb6c on github
  • Prev Job for on master (#25872754667.31)
  • Next Job for on master (#25873392065.22)
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