8000 Json Array in Body field of Validate does not return wrong type for Json Object · Issue #7 · jakecoffman/crud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Json Array in Body field of Validate does not return wrong type for Json Object #7
Closed
@matthewtylerwood

Description

@matthewtylerwood

Describe the bug

Validation of a json object body works, but validation of a json array body does not work.

To reproduce the bug

Create a validation spec similar to the following:

			Validate: crud.Validate{
				Body: crud.Array().Items(crud.String()),
			},

Then send a request body with something like {}. I would expect the error body validation failed for field body: wrong type passed, but no validation error occurs.

Any other details

On the flip side, passing a json array for a json object body does fail validation correctly. For example:

			Validate: crud.Validate{
				Body: crud.Object(map[string]crud.Field{
					"test": crud.String(),
				}),
			},

Then send a request body with something like []. I get the following validation error:

body validation failed for field body: wrong type passed

which is what I would expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      < 2920 /main>
      0