Skip to content

Enforce request body match validation schema #1148

@erakis

Description

@erakis

@fedeci

How to make sure the schema of the body is exactly of this form.

{
    'name': ...
    'description': ...
}

I mean if the body contains other fields than these (name, description), then I want to signal them by raising an exception.

Ex:

{
    'name': 'Bob'
    'description': 'Card player'
    'age' : 54
}

In this case, the validation should fail because the field age is not part of the wanted schema.

Obviously, it's possible to create a custom task, but it would be a great asset to have this functionality in express-validator. Some kind of matchSchema(true)?

Duplicate of #1101 (comment) but this issue has been closed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions