Skip to content

New options object for isHexColor breaks Array.filter #2660

@ninjatadpole

Description

@ninjatadpole

Describe the bug
Using Array.filter with isHexColor on an array of colour strings now throws an exception.

The exception is from the merge.js file because the new options object for isHexColor method is assumed to be param index 1, and is assumed to be an object. Array.filter automatically passes the current array index as param 1, which is not an object and which therefore cannot be merged with the default options.

Examples
The following will throw an exception:

import isHexColor from "validator/es/lib/isHexColor";
const validColors = ["#000000", "#FFFFFF"].filter(isHexColor);

Additional context
Validator version: 13.15.26
Pull request introducing the bug: validatorjs/validator.js/pull/2535
All node versions
All platforms

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