arktype 2.1.7 → 2.1.8

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.
package/out/generic.d.ts CHANGED
@@ -14,83 +14,43 @@ export type extractParams<s extends ParameterString> = s extends ParameterString
14
14
  export type validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends infer e extends ErrorMessage ? e : s;
15
15
  export type validateGenericArg<arg, param extends GenericParamAst, $> = type.infer<arg, $> extends param[1] ? unknown : ErrorType<`Invalid argument for ${param[0]}`, [expected: param[1]]>;
16
16
  export type GenericInstantiator<params extends array<GenericParamAst>, def, $, args$> = params["length"] extends 1 ? {
17
- <const a, r = instantiateGeneric<def, params, [a], $, args$>>(a: type.validate<a, args$> & validateGenericArg<a, params[0], args$>): r;
17
+ <const a, r = instantiateGeneric<def, params, [a], $, args$>>(a: type.validate<a, args$> & validateGenericArg<a, params[0], args$>): r extends infer _ ? _ : never;
18
18
  } : params["length"] extends 2 ? {
19
19
  <const a, const b, r = instantiateGeneric<def, params, [a, b], $, args$>>(...args: [
20
20
  type.validate<a, args$> & validateGenericArg<a, params[0], args$>,
21
21
  type.validate<b, args$> & validateGenericArg<b, params[1], args$>
22
- ]): r;
22
+ ]): r extends infer _ ? _ : never;
23
23
  } : params["length"] extends 3 ? {
24
24
  <const a, const b, const c, r = instantiateGeneric<def, params, [a, b, c], $, args$>>(...args: [
25
- type.validate<a, args$>,
26
- type.validate<b, args$>,
27
- type.validate<c, args$>
28
- ] & [
29
- validateGenericArg<a, params[0], args$>,
30
- validateGenericArg<b, params[1], args$>,
31
- validateGenericArg<c, params[2], args$>
32
- ]): r;
25
+ type.validate<a, args$> & validateGenericArg<a, params[0], args$>,
26
+ type.validate<b, args$> & validateGenericArg<b, params[1], args$>,
27
+ type.validate<c, args$> & validateGenericArg<c, params[2], args$>
28
+ ]): r extends infer _ ? _ : never;
33
29
  } : params["length"] extends 4 ? {
34
30
  <const a, const b, const c, const d, r = instantiateGeneric<def, params, [a, b, c, d], $, args$>>(...args: [
35
- type.validate<a, args$>,
36
- type.validate<b, args$>,
37
- type.validate<c, args$>,
38
- type.validate<d, args$>
39
- ] & [
40
- validateGenericArg<a, params[0], args$>,
41
- validateGenericArg<b, params[1], args$>,
42
- validateGenericArg<c, params[2], args$>,
43
- validateGenericArg<d, params[3], args$>
44
- ]): r;
45
- } : params["length"] extends 4 ? {
46
- <const a, const b, const c, const d, const e, r = instantiateGeneric<def, params, [a, b, c, d, e], $, args$>>(...args: [
47
- type.validate<a, args$>,
48
- type.validate<b, args$>,
49
- type.validate<c, args$>,
50
- type.validate<d, args$>,
51
- type.validate<e, args$>
52
- ] & [
53
- validateGenericArg<a, params[0], args$>,
54
- validateGenericArg<b, params[1], args$>,
55
- validateGenericArg<c, params[2], args$>,
56
- validateGenericArg<d, params[3], args$>,
57
- validateGenericArg<e, params[4], args$>
58
- ]): r;
31
+ type.validate<a, args$> & validateGenericArg<a, params[0], args$>,
32
+ type.validate<b, args$> & validateGenericArg<b, params[1], args$>,
33
+ type.validate<c, args$> & validateGenericArg<c, params[2], args$>,
34
+ type.validate<d, args$> & validateGenericArg<d, params[3], args$>
35
+ ]): r extends infer _ ? _ : never;
59
36
  } : params["length"] extends 5 ? {
60
- <const a, const b, const c, const d, const e, const f, r = instantiateGeneric<def, params, [a, b, c, d, e, f], $, args$>>(...args: [
61
- type.validate<a, args$>,
62
- type.validate<b, args$>,
63
- type.validate<c, args$>,
64
- type.validate<d, args$>,
65
- type.validate<e, args$>,
66
- type.validate<f, args$>
67
- ] & [
68
- validateGenericArg<a, params[0], args$>,
69
- validateGenericArg<b, params[1], args$>,
70
- validateGenericArg<c, params[2], args$>,
71
- validateGenericArg<d, params[3], args$>,
72
- validateGenericArg<e, params[4], args$>,
73
- validateGenericArg<f, params[5], args$>
74
- ]): r;
37
+ <const a, const b, const c, const d, const e, r = instantiateGeneric<def, params, [a, b, c, d, e], $, args$>>(...args: [
38
+ type.validate<a, args$> & validateGenericArg<a, params[0], args$>,
39
+ type.validate<b, args$> & validateGenericArg<b, params[1], args$>,
40
+ type.validate<c, args$> & validateGenericArg<c, params[2], args$>,
41
+ type.validate<d, args$> & validateGenericArg<d, params[3], args$>,
42
+ type.validate<e, args$> & validateGenericArg<e, params[4], args$>
43
+ ]): r extends infer _ ? _ : never;
75
44
  } : params["length"] extends 6 ? {
76
- <const a, const b, const c, const d, const e, const f, const g, r = instantiateGeneric<def, params, [a, b, c, d, e, f, g], $, args$>>(...args: [
77
- type.validate<a, args$>,
78
- type.validate<b, args$>,
79
- type.validate<c, args$>,
80
- type.validate<d, args$>,
81
- type.validate<e, args$>,
82
- type.validate<f, args$>,
83
- type.validate<g, args$>
84
- ] & [
85
- validateGenericArg<a, params[0], args$>,
86
- validateGenericArg<b, params[1], args$>,
87
- validateGenericArg<c, params[2], args$>,
88
- validateGenericArg<d, params[3], args$>,
89
- validateGenericArg<e, params[4], args$>,
90
- validateGenericArg<f, params[5], args$>,
91
- validateGenericArg<g, params[6], args$>
92
- ]): r;
93
- } : (error: ErrorMessage<`You may not define more than 7 positional generic parameters`>) => never;
45
+ <const a, const b, const c, const d, const e, const f, r = instantiateGeneric<def, params, [a, b, c, d, e, f], $, args$>>(...args: [
46
+ type.validate<a, args$> & validateGenericArg<a, params[0], args$>,
47
+ type.validate<b, args$> & validateGenericArg<b, params[1], args$>,
48
+ type.validate<c, args$> & validateGenericArg<c, params[2], args$>,
49
+ type.validate<d, args$> & validateGenericArg<d, params[3], args$>,
50
+ type.validate<e, args$> & validateGenericArg<e, params[4], args$>,
51
+ type.validate<f, args$> & validateGenericArg<f, params[5], args$>
52
+ ]): r extends infer _ ? _ : never;
53
+ } : (error: ErrorMessage<`You may not define more than 6 positional generic parameters`>) => never;
94
54
  type instantiateGeneric<def, params extends array<GenericParamAst>, args, $, args$> = Type<[
95
55
  def
96
56
  ] extends [Hkt] ? Hkt.apply<def, {
@@ -252,6 +252,7 @@ export declare const string: Module<{
252
252
  root: unknown;
253
253
  alpha: unknown;
254
254
  alphanumeric: unknown;
255
+ hex: unknown;
255
256
  base64: Submodule<{
256
257
  root: unknown;
257
258
  url: unknown;
@@ -308,6 +309,7 @@ export declare namespace string {
308
309
  root: string;
309
310
  alpha: string;
310
311
  alphanumeric: string;
312
+ hex: string;
311
313
  base64: base64.submodule;
312
314
  capitalize: capitalize.submodule;
313
315
  creditCard: string;
@@ -25,6 +25,7 @@ export const stringInteger = Scope.module({
25
25
  }, {
26
26
  name: "string.integer"
27
27
  });
28
+ const hex = regexStringNode(/^[0-9a-fA-F]+$/, "hex characters only");
28
29
  const base64 = Scope.module({
29
30
  root: regexStringNode(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/, "base64-encoded"),
30
31
  url: regexStringNode(/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==|%3D%3D)?|[A-Za-z0-9_-]{3}(?:=|%3D)?)?$/, "base64url-encoded")
@@ -418,6 +419,7 @@ export const string = Scope.module({
418
419
  root: intrinsic.string,
419
420
  alpha: regexStringNode(/^[A-Za-z]*$/, "only letters"),
420
421
  alphanumeric: regexStringNode(/^[A-Za-z\d]*$/, "only letters and digits 0-9"),
422
+ hex,
421
423
  base64,
422
424
  capitalize,
423
425
  creditCard,
@@ -135,11 +135,11 @@ export interface Inferred<out t = unknown, $ = {}> {
135
135
  * const criticalPayload = type({
136
136
  * superImportantValue: "string"
137
137
  * })
138
- * // throws AggregateError: superImportantValue must be a string (was missing)
138
+ * // throws TraversalError: superImportantValue must be a string (was missing)
139
139
  * const data = criticalPayload.assert({ irrelevantValue: "whoops" })
140
140
  * console.log(data.superImportantValue) // valid output can be accessed directly
141
141
  *
142
- * @throws {AggregateError}
142
+ * @throws {TraversalError}
143
143
  */
144
144
  assert(data: unknown): this["infer"];
145
145
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "Optimized runtime validation for TypeScript syntax",
4
- "version": "2.1.7",
4
+ "version": "2.1.8",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "out"
35
35
  ],
36
36
  "dependencies": {
37
- "@ark/util": "0.44.2",
38
- "@ark/schema": "0.44.2"
37
+ "@ark/util": "0.44.3",
38
+ "@ark/schema": "0.44.3"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"