Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Numbers that are strings are marked as invalid #345

@adwydman

Description

@adwydman

Let's say I have a the following object and validator configuration:

const myObject = {
  age: "24"
};
{
  age: {
    type: "number",
    numericality: {
      greaterThan: 0
    }
  }
}

The configuration will return an error Age must be of type number. The problem is that the documentation states:

Per default strings are coerced to numbers using the + operator.

While this is true, the logic has no chance of being hit - the type check is triggered first and throws an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions