arktypeio/arktype

Minor typo in runtime error message for negative length constraints

TizzySaurus opened this issue ยท 0 comments

Report a bug

๐Ÿ”Ž Search Terms

bound must be an integer; incorrect negative length error.

๐Ÿงฉ Context

  • ArkType version: 2.0.0-rc.6
  • TypeScript version (5.1+): 5.5.4
  • Other context you think may be relevant (JS flavor, OS, etc.): N/A

๐Ÿง‘โ€๐Ÿ’ป Repro

Currently the error states "must be an integer", which I suppose could be misleading since the issue isn't necessarily that the input wasn't an integer, but rather that it was negative.

import { rootNode } from "@ark/schema";

rootNode({ proto: "Array", minLength: -1});

Presumably the fix for this is to just update the message in writeNegativeLengthBoundMessage. Something like:

export const writeNegativeLengthBoundMessage = (
	kind: LengthBoundKind,
	limit: number
- ): string => `${kind} bound must be an integer (was ${limit})`
+ ): string => `${kind} bound must be a positive integer (was ${limit})`

A potential fix has been raised in #1125