Skip to content

isNumeric should reject for array #1323

@aemzayn

Description

@aemzayn

Describe the bug

The isNumeric should throw the error message for the array but it does not

To Reproduce

See this example code

[
 checkSchema({
    id: {
      in: ['body'],
      exists: {
        errorMessage: 'ID is required',
      },
      isNumeric: {
        errorMessage: 'ID must be a number',
      },
    },
  }),
]

When I send a request with this body:

{
  "id": []
}

It sees the array as a number and then it passes the validation

Expected behavior

IT should reject the request because the value is not a number

Current behavior

IT should reject the request because the value is not a number

Environment:

  • Express-validator version: 7.2.0
  • Express version: 4.21.2
  • Node.js version: 20.15.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions