"required" validators do not trigger for empty objects

Open
#1,862 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
api

Research direction

Start with the parameter validation path exercised by the params block and POST body shown in the issue. Add a regression test for { "foos": [{}] }; done means the missing required :bar is rejected rather than accepted.

Written by the indexing model from the issue text.

Description

bug?
        params do
          optional :foos, :type => Array do
            required :bar, :type => String
          end
        end

and then POSTing something like this:

{ "foos": [{}] }

Does not trigger validation, although the required :bar is missing.

I will try to at least submit a breaking test, or even a pull request.

Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby-grape/grape

All issues in ruby-grape/grape

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.