Skip to content

Make "number" reject Infinity, or make it easy to parse only finite numbers #1598

Closed

Description

@guillaumebrunerie

Request a feature

It should be easy to parse a finite number. In Zod 4, z.number() rejects ±Infinity, but ArkType's "number" seems to accept them.

🤷 Motivation

When parsing a number, it is usually pretty rare for Infinity or -Infinity to be a valid value, and also easy to forget about it. This means that by default, ArkType will often accept invalid data.

💡 Solution

My preferred solution would be to match Zod's behavior: to change "number" so that it rejects Infinity and -Infinity.

Alternatively, you could provide a "number.finite" primitive.

Activity

  1. pullfrog commented on Mar 15, 2026

    @pullfrog
    Contributor
  2. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  3. moved this from To do to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done (merged or closed)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions