Skip to content

isHexColor incorrectly validates hex colors without # #2533

Open
@mag123c

Description

@mag123c

The isHexColor function in validator.js currently allows strings like "6633FF" to pass validation as a valid hex color, even though a proper hex color should include a leading #. This issue arises from the current regex implementation in the library.

https://github.com/validatorjs/validator.js/blob/master/src/lib/isHexColor.js

Is allowing hex colors without # an intended behavior in isHexColor? If not, can I submit a fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions