arktype 2.0.0-rc.25 → 2.0.0-rc.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { intrinsic, rootSchema } from "@ark/schema";
|
|
2
|
-
import {
|
|
2
|
+
import { numericStringMatcher } from "@ark/util";
|
|
3
3
|
import { arkModule } from "../utils.js";
|
|
4
4
|
import { regexStringNode } from "./utils.js";
|
|
5
|
-
const root = regexStringNode(
|
|
5
|
+
const root = regexStringNode(numericStringMatcher, "a well-formed numeric string");
|
|
6
6
|
export const numeric = arkModule({
|
|
7
7
|
root,
|
|
8
8
|
parse: rootSchema({
|
|
@@ -41,7 +41,7 @@ export const getBoundKinds = (comparator, limit, root, boundKind) => {
|
|
|
41
41
|
if (typeof limit !== "number") {
|
|
42
42
|
return throwParseError(writeInvalidLimitMessage(comparator, limit, boundKind));
|
|
43
43
|
}
|
|
44
|
-
return (comparator === "==" ? ["
|
|
44
|
+
return (comparator === "==" ? ["exactLength"]
|
|
45
45
|
: comparator[0] === ">" ? ["minLength"]
|
|
46
46
|
: ["maxLength"]);
|
|
47
47
|
}
|
|
@@ -75,9 +75,10 @@ export const parseRightBound = (s, comparator) => {
|
|
|
75
75
|
const limit = limitNode.unit;
|
|
76
76
|
// apply the newly-parsed right bound
|
|
77
77
|
const exclusive = comparator.length === 1;
|
|
78
|
-
|
|
79
|
-
for (const kind of
|
|
80
|
-
s.constrainRoot(kind, { rule: limit, exclusive });
|
|
78
|
+
const boundKinds = getBoundKinds(comparator, typeof limit === "number" ? limit : limitToken, previousRoot, "right");
|
|
79
|
+
for (const kind of boundKinds) {
|
|
80
|
+
s.constrainRoot(kind, comparator === "==" ? { rule: limit } : { rule: limit, exclusive });
|
|
81
|
+
}
|
|
81
82
|
if (!s.branches.leftBound)
|
|
82
83
|
return;
|
|
83
84
|
// if there's an open left bound, perform additional validation and apply it
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arktype",
|
|
3
3
|
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.26",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "David Blass",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"out"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ark/
|
|
38
|
-
"@ark/
|
|
37
|
+
"@ark/schema": "0.26.0",
|
|
38
|
+
"@ark/util": "0.26.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|