effect 3.11.6 → 3.11.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/dist/cjs/Arbitrary.js +46 -4
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/JSONSchema.js +157 -38
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Schema.js +63 -51
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/schema/{filters.js → schemaId.js} +4 -2
- package/dist/cjs/internal/schema/schemaId.js.map +1 -0
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Arbitrary.d.ts +5 -1
- package/dist/dts/Arbitrary.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +11 -2
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +16 -6
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/schema/schemaId.d.ts +2 -0
- package/dist/dts/internal/schema/schemaId.d.ts.map +1 -0
- package/dist/esm/Arbitrary.js +44 -3
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/JSONSchema.js +157 -38
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Schema.js +55 -43
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/schema/{filters.js → schemaId.js} +3 -1
- package/dist/esm/internal/schema/schemaId.js.map +1 -0
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +64 -13
- package/src/JSONSchema.ts +185 -40
- package/src/Schema.ts +65 -50
- package/src/internal/schema/{filters.ts → schemaId.ts} +5 -0
- package/src/internal/version.ts +1 -1
- package/dist/cjs/internal/schema/filters.js.map +0 -1
- package/dist/dts/internal/schema/filters.d.ts +0 -2
- package/dist/dts/internal/schema/filters.d.ts.map +0 -1
- package/dist/esm/internal/schema/filters.js.map +0 -1
package/dist/esm/Schema.js
CHANGED
|
@@ -25,7 +25,7 @@ import { globalValue } from "./GlobalValue.js";
|
|
|
25
25
|
import * as hashMap_ from "./HashMap.js";
|
|
26
26
|
import * as hashSet_ from "./HashSet.js";
|
|
27
27
|
import * as errors_ from "./internal/schema/errors.js";
|
|
28
|
-
import * as
|
|
28
|
+
import * as schemaId_ from "./internal/schema/schemaId.js";
|
|
29
29
|
import * as util_ from "./internal/schema/util.js";
|
|
30
30
|
import * as list_ from "./List.js";
|
|
31
31
|
import * as number_ from "./Number.js";
|
|
@@ -1744,7 +1744,7 @@ export const trimmed = annotations => self => self.pipe(filter(a => a === a.trim
|
|
|
1744
1744
|
* @category schema id
|
|
1745
1745
|
* @since 3.10.0
|
|
1746
1746
|
*/
|
|
1747
|
-
export const MaxLengthSchemaId =
|
|
1747
|
+
export const MaxLengthSchemaId = schemaId_.MaxLengthSchemaId;
|
|
1748
1748
|
/**
|
|
1749
1749
|
* @category string filters
|
|
1750
1750
|
* @since 3.10.0
|
|
@@ -1761,7 +1761,7 @@ export const maxLength = (maxLength, annotations) => self => self.pipe(filter(a
|
|
|
1761
1761
|
* @category schema id
|
|
1762
1762
|
* @since 3.10.0
|
|
1763
1763
|
*/
|
|
1764
|
-
export const MinLengthSchemaId =
|
|
1764
|
+
export const MinLengthSchemaId = schemaId_.MinLengthSchemaId;
|
|
1765
1765
|
/**
|
|
1766
1766
|
* @category string filters
|
|
1767
1767
|
* @since 3.10.0
|
|
@@ -1973,7 +1973,7 @@ export class Uppercased extends /*#__PURE__*/String$.pipe( /*#__PURE__*/uppercas
|
|
|
1973
1973
|
* @category schema id
|
|
1974
1974
|
* @since 3.10.0
|
|
1975
1975
|
*/
|
|
1976
|
-
export const LengthSchemaId =
|
|
1976
|
+
export const LengthSchemaId = schemaId_.LengthSchemaId;
|
|
1977
1977
|
/**
|
|
1978
1978
|
* @category string filters
|
|
1979
1979
|
* @since 3.10.0
|
|
@@ -2268,7 +2268,7 @@ URL$ as URL };
|
|
|
2268
2268
|
* @category schema id
|
|
2269
2269
|
* @since 3.10.0
|
|
2270
2270
|
*/
|
|
2271
|
-
export const FiniteSchemaId =
|
|
2271
|
+
export const FiniteSchemaId = schemaId_.FiniteSchemaId;
|
|
2272
2272
|
/**
|
|
2273
2273
|
* Ensures that the provided value is a finite number.
|
|
2274
2274
|
*
|
|
@@ -2289,18 +2289,18 @@ export const finite = annotations => self => self.pipe(filter(Number.isFinite, {
|
|
|
2289
2289
|
* @category schema id
|
|
2290
2290
|
* @since 3.10.0
|
|
2291
2291
|
*/
|
|
2292
|
-
export const GreaterThanSchemaId =
|
|
2292
|
+
export const GreaterThanSchemaId = schemaId_.GreaterThanSchemaId;
|
|
2293
2293
|
/**
|
|
2294
2294
|
* This filter checks whether the provided number is greater than the specified minimum.
|
|
2295
2295
|
*
|
|
2296
2296
|
* @category number filters
|
|
2297
2297
|
* @since 3.10.0
|
|
2298
2298
|
*/
|
|
2299
|
-
export const greaterThan = (
|
|
2299
|
+
export const greaterThan = (exclusiveMinimum, annotations) => self => self.pipe(filter(a => a > exclusiveMinimum, {
|
|
2300
2300
|
schemaId: GreaterThanSchemaId,
|
|
2301
|
-
description:
|
|
2301
|
+
description: exclusiveMinimum === 0 ? "a positive number" : `a number greater than ${exclusiveMinimum}`,
|
|
2302
2302
|
jsonSchema: {
|
|
2303
|
-
exclusiveMinimum
|
|
2303
|
+
exclusiveMinimum
|
|
2304
2304
|
},
|
|
2305
2305
|
...annotations
|
|
2306
2306
|
}));
|
|
@@ -2308,18 +2308,18 @@ export const greaterThan = (min, annotations) => self => self.pipe(filter(a => a
|
|
|
2308
2308
|
* @category schema id
|
|
2309
2309
|
* @since 3.10.0
|
|
2310
2310
|
*/
|
|
2311
|
-
export const GreaterThanOrEqualToSchemaId =
|
|
2311
|
+
export const GreaterThanOrEqualToSchemaId = schemaId_.GreaterThanOrEqualToSchemaId;
|
|
2312
2312
|
/**
|
|
2313
2313
|
* This filter checks whether the provided number is greater than or equal to the specified minimum.
|
|
2314
2314
|
*
|
|
2315
2315
|
* @category number filters
|
|
2316
2316
|
* @since 3.10.0
|
|
2317
2317
|
*/
|
|
2318
|
-
export const greaterThanOrEqualTo = (
|
|
2318
|
+
export const greaterThanOrEqualTo = (minimum, annotations) => self => self.pipe(filter(a => a >= minimum, {
|
|
2319
2319
|
schemaId: GreaterThanOrEqualToSchemaId,
|
|
2320
|
-
description:
|
|
2320
|
+
description: minimum === 0 ? "a non-negative number" : `a number greater than or equal to ${minimum}`,
|
|
2321
2321
|
jsonSchema: {
|
|
2322
|
-
minimum
|
|
2322
|
+
minimum
|
|
2323
2323
|
},
|
|
2324
2324
|
...annotations
|
|
2325
2325
|
}));
|
|
@@ -2345,7 +2345,7 @@ export const multipleOf = (divisor, annotations) => self => self.pipe(filter(a =
|
|
|
2345
2345
|
* @category schema id
|
|
2346
2346
|
* @since 3.10.0
|
|
2347
2347
|
*/
|
|
2348
|
-
export const IntSchemaId =
|
|
2348
|
+
export const IntSchemaId = schemaId_.IntSchemaId;
|
|
2349
2349
|
/**
|
|
2350
2350
|
* @category number filters
|
|
2351
2351
|
* @since 3.10.0
|
|
@@ -2363,18 +2363,18 @@ export const int = annotations => self => self.pipe(filter(a => Number.isSafeInt
|
|
|
2363
2363
|
* @category schema id
|
|
2364
2364
|
* @since 3.10.0
|
|
2365
2365
|
*/
|
|
2366
|
-
export const LessThanSchemaId =
|
|
2366
|
+
export const LessThanSchemaId = schemaId_.LessThanSchemaId;
|
|
2367
2367
|
/**
|
|
2368
2368
|
* This filter checks whether the provided number is less than the specified maximum.
|
|
2369
2369
|
*
|
|
2370
2370
|
* @category number filters
|
|
2371
2371
|
* @since 3.10.0
|
|
2372
2372
|
*/
|
|
2373
|
-
export const lessThan = (
|
|
2373
|
+
export const lessThan = (exclusiveMaximum, annotations) => self => self.pipe(filter(a => a < exclusiveMaximum, {
|
|
2374
2374
|
schemaId: LessThanSchemaId,
|
|
2375
|
-
description:
|
|
2375
|
+
description: exclusiveMaximum === 0 ? "a negative number" : `a number less than ${exclusiveMaximum}`,
|
|
2376
2376
|
jsonSchema: {
|
|
2377
|
-
exclusiveMaximum
|
|
2377
|
+
exclusiveMaximum
|
|
2378
2378
|
},
|
|
2379
2379
|
...annotations
|
|
2380
2380
|
}));
|
|
@@ -2382,18 +2382,18 @@ export const lessThan = (max, annotations) => self => self.pipe(filter(a => a <
|
|
|
2382
2382
|
* @category schema id
|
|
2383
2383
|
* @since 3.10.0
|
|
2384
2384
|
*/
|
|
2385
|
-
export const LessThanOrEqualToSchemaId =
|
|
2385
|
+
export const LessThanOrEqualToSchemaId = schemaId_.LessThanOrEqualToSchemaId;
|
|
2386
2386
|
/**
|
|
2387
2387
|
* This schema checks whether the provided number is less than or equal to the specified maximum.
|
|
2388
2388
|
*
|
|
2389
2389
|
* @category number filters
|
|
2390
2390
|
* @since 3.10.0
|
|
2391
2391
|
*/
|
|
2392
|
-
export const lessThanOrEqualTo = (
|
|
2392
|
+
export const lessThanOrEqualTo = (maximum, annotations) => self => self.pipe(filter(a => a <= maximum, {
|
|
2393
2393
|
schemaId: LessThanOrEqualToSchemaId,
|
|
2394
|
-
description:
|
|
2394
|
+
description: maximum === 0 ? "a non-positive number" : `a number less than or equal to ${maximum}`,
|
|
2395
2395
|
jsonSchema: {
|
|
2396
|
-
maximum
|
|
2396
|
+
maximum
|
|
2397
2397
|
},
|
|
2398
2398
|
...annotations
|
|
2399
2399
|
}));
|
|
@@ -2401,19 +2401,19 @@ export const lessThanOrEqualTo = (max, annotations) => self => self.pipe(filter(
|
|
|
2401
2401
|
* @category schema id
|
|
2402
2402
|
* @since 3.10.0
|
|
2403
2403
|
*/
|
|
2404
|
-
export const BetweenSchemaId =
|
|
2404
|
+
export const BetweenSchemaId = schemaId_.BetweenSchemaId;
|
|
2405
2405
|
/**
|
|
2406
2406
|
* This filter checks whether the provided number falls within the specified minimum and maximum values.
|
|
2407
2407
|
*
|
|
2408
2408
|
* @category number filters
|
|
2409
2409
|
* @since 3.10.0
|
|
2410
2410
|
*/
|
|
2411
|
-
export const between = (
|
|
2411
|
+
export const between = (minimum, maximum, annotations) => self => self.pipe(filter(a => a >= minimum && a <= maximum, {
|
|
2412
2412
|
schemaId: BetweenSchemaId,
|
|
2413
|
-
description: `a number between ${
|
|
2413
|
+
description: `a number between ${minimum} and ${maximum}`,
|
|
2414
2414
|
jsonSchema: {
|
|
2415
|
-
|
|
2416
|
-
|
|
2415
|
+
minimum,
|
|
2416
|
+
maximum
|
|
2417
2417
|
},
|
|
2418
2418
|
...annotations
|
|
2419
2419
|
}));
|
|
@@ -2421,7 +2421,7 @@ export const between = (min, max, annotations) => self => self.pipe(filter(a =>
|
|
|
2421
2421
|
* @category schema id
|
|
2422
2422
|
* @since 3.10.0
|
|
2423
2423
|
*/
|
|
2424
|
-
export const NonNaNSchemaId =
|
|
2424
|
+
export const NonNaNSchemaId = schemaId_.NonNaNSchemaId;
|
|
2425
2425
|
/**
|
|
2426
2426
|
* @category number filters
|
|
2427
2427
|
* @since 3.10.0
|
|
@@ -2555,7 +2555,7 @@ export class NonNegative extends /*#__PURE__*/Number$.pipe( /*#__PURE__*/nonNega
|
|
|
2555
2555
|
* @category schema id
|
|
2556
2556
|
* @since 3.10.0
|
|
2557
2557
|
*/
|
|
2558
|
-
export const JsonNumberSchemaId =
|
|
2558
|
+
export const JsonNumberSchemaId = schemaId_.JsonNumberSchemaId;
|
|
2559
2559
|
/**
|
|
2560
2560
|
* The `JsonNumber` is a schema for representing JSON numbers. It ensures that the provided value is a valid
|
|
2561
2561
|
* number by filtering out `NaN` and `(+/-) Infinity`. This is useful when you want to validate and represent numbers in JSON
|
|
@@ -2615,7 +2615,7 @@ Symbol$ as Symbol };
|
|
|
2615
2615
|
* @category schema id
|
|
2616
2616
|
* @since 3.10.0
|
|
2617
2617
|
*/
|
|
2618
|
-
export const GreaterThanBigIntSchemaId =
|
|
2618
|
+
export const GreaterThanBigIntSchemaId = schemaId_.GreaterThanBigintSchemaId;
|
|
2619
2619
|
/**
|
|
2620
2620
|
* @category bigint filters
|
|
2621
2621
|
* @since 3.10.0
|
|
@@ -2632,7 +2632,7 @@ export const greaterThanBigInt = (min, annotations) => self => self.pipe(filter(
|
|
|
2632
2632
|
* @category schema id
|
|
2633
2633
|
* @since 3.10.0
|
|
2634
2634
|
*/
|
|
2635
|
-
export const GreaterThanOrEqualToBigIntSchemaId =
|
|
2635
|
+
export const GreaterThanOrEqualToBigIntSchemaId = schemaId_.GreaterThanOrEqualToBigIntSchemaId;
|
|
2636
2636
|
/**
|
|
2637
2637
|
* @category bigint filters
|
|
2638
2638
|
* @since 3.10.0
|
|
@@ -2649,7 +2649,7 @@ export const greaterThanOrEqualToBigInt = (min, annotations) => self => self.pip
|
|
|
2649
2649
|
* @category schema id
|
|
2650
2650
|
* @since 3.10.0
|
|
2651
2651
|
*/
|
|
2652
|
-
export const LessThanBigIntSchemaId =
|
|
2652
|
+
export const LessThanBigIntSchemaId = schemaId_.LessThanBigIntSchemaId;
|
|
2653
2653
|
/**
|
|
2654
2654
|
* @category bigint filters
|
|
2655
2655
|
* @since 3.10.0
|
|
@@ -2666,7 +2666,7 @@ export const lessThanBigInt = (max, annotations) => self => self.pipe(filter(a =
|
|
|
2666
2666
|
* @category schema id
|
|
2667
2667
|
* @since 3.10.0
|
|
2668
2668
|
*/
|
|
2669
|
-
export const LessThanOrEqualToBigIntSchemaId =
|
|
2669
|
+
export const LessThanOrEqualToBigIntSchemaId = schemaId_.LessThanOrEqualToBigIntSchemaId;
|
|
2670
2670
|
/**
|
|
2671
2671
|
* @category bigint filters
|
|
2672
2672
|
* @since 3.10.0
|
|
@@ -2683,7 +2683,7 @@ export const lessThanOrEqualToBigInt = (max, annotations) => self => self.pipe(f
|
|
|
2683
2683
|
* @category schema id
|
|
2684
2684
|
* @since 3.10.0
|
|
2685
2685
|
*/
|
|
2686
|
-
export const BetweenBigIntSchemaId =
|
|
2686
|
+
export const BetweenBigIntSchemaId = schemaId_.BetweenBigintSchemaId;
|
|
2687
2687
|
/**
|
|
2688
2688
|
* @category bigint filters
|
|
2689
2689
|
* @since 3.10.0
|
|
@@ -2691,8 +2691,8 @@ export const BetweenBigIntSchemaId = filters_.BetweenBigintSchemaId;
|
|
|
2691
2691
|
export const betweenBigInt = (min, max, annotations) => self => self.pipe(filter(a => a >= min && a <= max, {
|
|
2692
2692
|
schemaId: BetweenBigIntSchemaId,
|
|
2693
2693
|
[BetweenBigIntSchemaId]: {
|
|
2694
|
-
|
|
2695
|
-
|
|
2694
|
+
min,
|
|
2695
|
+
max
|
|
2696
2696
|
},
|
|
2697
2697
|
description: `a bigint between ${min}n and ${max}n`,
|
|
2698
2698
|
...annotations
|
|
@@ -3128,7 +3128,7 @@ export const StringFromHex = /*#__PURE__*/makeEncodingTransformation("Hex", Enco
|
|
|
3128
3128
|
* @category schema id
|
|
3129
3129
|
* @since 3.10.0
|
|
3130
3130
|
*/
|
|
3131
|
-
export const MinItemsSchemaId =
|
|
3131
|
+
export const MinItemsSchemaId = schemaId_.MinItemsSchemaId;
|
|
3132
3132
|
/**
|
|
3133
3133
|
* @category ReadonlyArray filters
|
|
3134
3134
|
* @since 3.10.0
|
|
@@ -3152,7 +3152,7 @@ export const minItems = (n, annotations) => self => {
|
|
|
3152
3152
|
* @category schema id
|
|
3153
3153
|
* @since 3.10.0
|
|
3154
3154
|
*/
|
|
3155
|
-
export const MaxItemsSchemaId =
|
|
3155
|
+
export const MaxItemsSchemaId = schemaId_.MaxItemsSchemaId;
|
|
3156
3156
|
/**
|
|
3157
3157
|
* @category ReadonlyArray filters
|
|
3158
3158
|
* @since 3.10.0
|
|
@@ -3170,7 +3170,7 @@ export const maxItems = (n, annotations) => self => self.pipe(filter(a => a.leng
|
|
|
3170
3170
|
* @category schema id
|
|
3171
3171
|
* @since 3.10.0
|
|
3172
3172
|
*/
|
|
3173
|
-
export const ItemsCountSchemaId =
|
|
3173
|
+
export const ItemsCountSchemaId = schemaId_.ItemsCountSchemaId;
|
|
3174
3174
|
/**
|
|
3175
3175
|
* @category ReadonlyArray filters
|
|
3176
3176
|
* @since 3.10.0
|
|
@@ -3233,6 +3233,9 @@ export const ValidDateSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/ValidD
|
|
|
3233
3233
|
*/
|
|
3234
3234
|
export const validDate = annotations => self => self.pipe(filter(a => !Number.isNaN(a.getTime()), {
|
|
3235
3235
|
schemaId: ValidDateSchemaId,
|
|
3236
|
+
[ValidDateSchemaId]: {
|
|
3237
|
+
noInvalidDate: true
|
|
3238
|
+
},
|
|
3236
3239
|
description: "a valid Date",
|
|
3237
3240
|
...annotations
|
|
3238
3241
|
}));
|
|
@@ -3313,15 +3316,20 @@ export const BetweenDateSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Betw
|
|
|
3313
3316
|
* @category Date filters
|
|
3314
3317
|
* @since 3.10.0
|
|
3315
3318
|
*/
|
|
3316
|
-
export const betweenDate = (
|
|
3319
|
+
export const betweenDate = (min, max, annotations) => self => self.pipe(filter(a => a <= max && a >= min, {
|
|
3317
3320
|
schemaId: BetweenDateSchemaId,
|
|
3318
3321
|
[BetweenDateSchemaId]: {
|
|
3319
|
-
|
|
3320
|
-
|
|
3322
|
+
max,
|
|
3323
|
+
min
|
|
3321
3324
|
},
|
|
3322
|
-
description: `a date between ${util_.formatDate(
|
|
3325
|
+
description: `a date between ${util_.formatDate(min)} and ${util_.formatDate(max)}`,
|
|
3323
3326
|
...annotations
|
|
3324
3327
|
}));
|
|
3328
|
+
/**
|
|
3329
|
+
* @category schema id
|
|
3330
|
+
* @since 3.11.8
|
|
3331
|
+
*/
|
|
3332
|
+
export const DateFromSelfSchemaId = schemaId_.DateFromSelfSchemaId;
|
|
3325
3333
|
/**
|
|
3326
3334
|
* Describes a schema that accommodates potentially invalid `Date` instances,
|
|
3327
3335
|
* such as `new Date("Invalid Date")`, without rejection.
|
|
@@ -3331,6 +3339,10 @@ export const betweenDate = (minimum, maximum, annotations) => self => self.pipe(
|
|
|
3331
3339
|
*/
|
|
3332
3340
|
export class DateFromSelf extends /*#__PURE__*/declare(Predicate.isDate, {
|
|
3333
3341
|
identifier: "DateFromSelf",
|
|
3342
|
+
schemaId: DateFromSelfSchemaId,
|
|
3343
|
+
[DateFromSelfSchemaId]: {
|
|
3344
|
+
noInvalidDate: false
|
|
3345
|
+
},
|
|
3334
3346
|
description: "a potentially invalid Date instance",
|
|
3335
3347
|
pretty: () => date => `new Date(${JSON.stringify(date)})`,
|
|
3336
3348
|
arbitrary: () => fc => fc.date({
|