question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sanitizing arrays loses data except first item

See original GitHub issue

Version: express-validator 6.2.0

Send POST data:

{
title: "test",
genre: ["aaa", "bbb", "ccc"]
}

After sanitizeBody("*").escape() POST data changed to:

{
title: "test",
genre: "aaa"
}

And array data of genre lost!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fedecicommented, Dec 28, 2020

@favph Sure I will, however to require a minimum array length you can use isArray({ min: 1 })

1reaction
JustinChowcommented, Jul 4, 2020

Seeing the same issue in v6.14.5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP: array values lost after for each - Stack Overflow
I've got an array of user items, consisting of an ID(item_id) and quantity(e.g. 10 items) If a user purchases an item, it's added...
Read more >
Sanitizing Arrays: The WordPress Settings API - Tom McFarlin
Here is Part 1. Yesterday, I started talking about how to sanitize multiple values with the WordPress Settings API.
Read more >
Weird validation where field is an array · Issue #883 · express ...
Doesn't matter the values are array, it seems to only check if the first element is valid. Is this expected behavior?
Read more >
10 Most Common Mistakes That PHP Developers Make - Toptal
Just a warning: When using non-empty arrays, count($array) can slow down your code significantly. What's more, some developers tend to use if(count($arr)) ......
Read more >
MyProgrammingLab Starting out with Python Ch.7 - Quizlet
Given that a variable named plist has been defined and refers to a non-empty list, write a statement that associates its first element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found