@atproto/lex-schema 0.0.19 → 0.1.0-next.0
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/CHANGELOG.md +26 -0
- package/dist/core/$type.js +2 -6
- package/dist/core/$type.js.map +1 -1
- package/dist/core/record-key.js +4 -8
- package/dist/core/record-key.js.map +1 -1
- package/dist/core/result.js +6 -14
- package/dist/core/result.js.map +1 -1
- package/dist/core/schema.js +16 -20
- package/dist/core/schema.js.map +1 -1
- package/dist/core/standard-schema.js +5 -10
- package/dist/core/standard-schema.js.map +1 -1
- package/dist/core/string-format.d.ts.map +1 -1
- package/dist/core/string-format.js +37 -61
- package/dist/core/string-format.js.map +1 -1
- package/dist/core/types.js +1 -2
- package/dist/core/validation-error.js +14 -25
- package/dist/core/validation-error.js.map +1 -1
- package/dist/core/validation-issue.js +13 -41
- package/dist/core/validation-issue.js.map +1 -1
- package/dist/core/validator.js +19 -28
- package/dist/core/validator.js.map +1 -1
- package/dist/core.js +9 -12
- package/dist/core.js.map +1 -1
- package/dist/external.js +3 -6
- package/dist/external.js.map +1 -1
- package/dist/helpers.js +5 -9
- package/dist/helpers.js.map +1 -1
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/dist/schema/array.js +5 -11
- package/dist/schema/array.js.map +1 -1
- package/dist/schema/blob.js +10 -17
- package/dist/schema/blob.js.map +1 -1
- package/dist/schema/boolean.js +8 -9
- package/dist/schema/boolean.js.map +1 -1
- package/dist/schema/bytes.js +7 -12
- package/dist/schema/bytes.js.map +1 -1
- package/dist/schema/cid.js +7 -12
- package/dist/schema/cid.js.map +1 -1
- package/dist/schema/custom.js +5 -13
- package/dist/schema/custom.js.map +1 -1
- package/dist/schema/dict.js +6 -13
- package/dist/schema/dict.js.map +1 -1
- package/dist/schema/discriminated-union.js +10 -18
- package/dist/schema/discriminated-union.js.map +1 -1
- package/dist/schema/enum.js +6 -11
- package/dist/schema/enum.js.map +1 -1
- package/dist/schema/integer.js +5 -10
- package/dist/schema/integer.js.map +1 -1
- package/dist/schema/intersection.js +4 -11
- package/dist/schema/intersection.js.map +1 -1
- package/dist/schema/lex-map.js +13 -14
- package/dist/schema/lex-map.js.map +1 -1
- package/dist/schema/lex-value.js +11 -12
- package/dist/schema/lex-value.js.map +1 -1
- package/dist/schema/literal.js +4 -10
- package/dist/schema/literal.js.map +1 -1
- package/dist/schema/never.js +8 -9
- package/dist/schema/never.js.map +1 -1
- package/dist/schema/null.js +9 -10
- package/dist/schema/null.js.map +1 -1
- package/dist/schema/nullable.js +5 -10
- package/dist/schema/nullable.js.map +1 -1
- package/dist/schema/object.js +8 -14
- package/dist/schema/object.js.map +1 -1
- package/dist/schema/optional.js +5 -10
- package/dist/schema/optional.js.map +1 -1
- package/dist/schema/params.js +39 -44
- package/dist/schema/params.js.map +1 -1
- package/dist/schema/payload.js +5 -13
- package/dist/schema/payload.js.map +1 -1
- package/dist/schema/permission-set.js +2 -10
- package/dist/schema/permission-set.js.map +1 -1
- package/dist/schema/permission.js +2 -9
- package/dist/schema/permission.js.map +1 -1
- package/dist/schema/procedure.js +3 -13
- package/dist/schema/procedure.js.map +1 -1
- package/dist/schema/query.js +3 -12
- package/dist/schema/query.js.map +1 -1
- package/dist/schema/record.js +15 -24
- package/dist/schema/record.js.map +1 -1
- package/dist/schema/ref.js +4 -9
- package/dist/schema/ref.js.map +1 -1
- package/dist/schema/refine.js +3 -6
- package/dist/schema/refine.js.map +1 -1
- package/dist/schema/regexp.js +4 -11
- package/dist/schema/regexp.js.map +1 -1
- package/dist/schema/string.js +15 -26
- package/dist/schema/string.js.map +1 -1
- package/dist/schema/subscription.js +3 -12
- package/dist/schema/subscription.js.map +1 -1
- package/dist/schema/token.js +5 -11
- package/dist/schema/token.js.map +1 -1
- package/dist/schema/typed-object.js +11 -18
- package/dist/schema/typed-object.js.map +1 -1
- package/dist/schema/typed-ref.js +4 -9
- package/dist/schema/typed-ref.js.map +1 -1
- package/dist/schema/typed-union.js +8 -15
- package/dist/schema/typed-union.js.map +1 -1
- package/dist/schema/union.js +5 -11
- package/dist/schema/union.js.map +1 -1
- package/dist/schema/unknown.js +8 -9
- package/dist/schema/unknown.js.map +1 -1
- package/dist/schema/with-default.js +4 -11
- package/dist/schema/with-default.js.map +1 -1
- package/dist/schema.js +38 -41
- package/dist/schema.js.map +1 -1
- package/dist/util/array-agg.js +1 -4
- package/dist/util/array-agg.js.map +1 -1
- package/dist/util/assertion-util.js +1 -2
- package/dist/util/if-any.js +1 -2
- package/dist/util/lazy-property.js +1 -4
- package/dist/util/lazy-property.js.map +1 -1
- package/dist/util/memoize.js +2 -6
- package/dist/util/memoize.js.map +1 -1
- package/package.json +7 -8
- package/src/core/string-format.ts +2 -1
- package/src/core/validation-issue.ts +1 -1
- package/src/helpers.test.ts +52 -52
- package/src/schema/record.test.ts +2 -2
- package/src/schema/ref.test.ts +1 -1
- package/src/schema/string.test.ts +6 -6
- package/src/schema/subscription.test.ts +4 -4
- package/src/schema/typed-object.test.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.js","sourceRoot":"","sources":["../../src/schema/integer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integer.js","sourceRoot":"","sources":["../../src/schema/integer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAapD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,aAAc,SAAQ,MAAc;IAG/C,YAAqB,OAA8B;QACjD,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAuB;QAF1C,SAAI,GAAG,SAAkB,CAAA;IAIlC,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAClD,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClE,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClE,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACvE,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,eAAe,CAAC,UACnD,OAA8B;IAE9B,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;AACnC,CAAC,CAAC,CAAA","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\n/**\n * Configuration options for integer schema validation.\n *\n * @property minimum - Minimum allowed value (inclusive)\n * @property maximum - Maximum allowed value (inclusive)\n */\nexport type IntegerSchemaOptions = {\n minimum?: number\n maximum?: number\n}\n\n/**\n * Schema for validating integer values with optional range constraints.\n *\n * Only accepts safe integers (values that can be exactly represented in JavaScript).\n * Use {@link IntegerSchemaOptions} to constrain the allowed range.\n *\n * @example\n * ```ts\n * const schema = new IntegerSchema({ minimum: 0, maximum: 100 })\n * const result = schema.validate(42)\n * ```\n */\nexport class IntegerSchema extends Schema<number> {\n readonly type = 'integer' as const\n\n constructor(readonly options?: IntegerSchemaOptions) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (!isInteger(input)) {\n return ctx.issueUnexpectedType(input, 'integer')\n }\n\n if (this.options?.minimum != null && input < this.options.minimum) {\n return ctx.issueTooSmall(input, 'integer', this.options.minimum, input)\n }\n\n if (this.options?.maximum != null && input > this.options.maximum) {\n return ctx.issueTooBig(input, 'integer', this.options.maximum, input)\n }\n\n return ctx.success(input)\n }\n}\n\n/**\n * Simple wrapper around {@link Number.isSafeInteger} that acts as a type guard.\n */\nfunction isInteger(input: unknown): input is number {\n return Number.isSafeInteger(input)\n}\n\n/**\n * Creates an integer schema with optional minimum and maximum constraints.\n *\n * Validates that the input is a safe integer (can be exactly represented in JavaScript)\n * and optionally falls within a specified range.\n *\n * @param options - Optional configuration for minimum and maximum values\n * @returns A new {@link IntegerSchema} instance\n *\n * @example\n * ```ts\n * // Basic integer\n * const countSchema = l.integer()\n *\n * // With minimum value\n * const positiveSchema = l.integer({ minimum: 1 })\n *\n * // With range constraints\n * const percentSchema = l.integer({ minimum: 0, maximum: 100 })\n *\n * // Age validation\n * const ageSchema = l.integer({ minimum: 0, maximum: 150 })\n * ```\n */\nexport const integer = /*#__PURE__*/ memoizedOptions(function (\n options?: IntegerSchemaOptions,\n) {\n return new IntegerSchema(options)\n})\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntersectionSchema = void 0;
|
|
4
|
-
exports.intersection = intersection;
|
|
5
|
-
const core_js_1 = require("../core.js");
|
|
1
|
+
import { Schema, } from '../core.js';
|
|
6
2
|
/**
|
|
7
3
|
* Schema for combining an object schema with a dictionary schema.
|
|
8
4
|
*
|
|
@@ -23,14 +19,12 @@ const core_js_1 = require("../core.js");
|
|
|
23
19
|
* // Validates: { name: 'test', score: 100, count: 5 }
|
|
24
20
|
* ```
|
|
25
21
|
*/
|
|
26
|
-
class IntersectionSchema extends
|
|
27
|
-
left;
|
|
28
|
-
right;
|
|
29
|
-
type = 'intersection';
|
|
22
|
+
export class IntersectionSchema extends Schema {
|
|
30
23
|
constructor(left, right) {
|
|
31
24
|
super();
|
|
32
25
|
this.left = left;
|
|
33
26
|
this.right = right;
|
|
27
|
+
this.type = 'intersection';
|
|
34
28
|
}
|
|
35
29
|
validateInContext(input, ctx) {
|
|
36
30
|
const leftResult = ctx.validate(input, this.left);
|
|
@@ -41,7 +35,6 @@ class IntersectionSchema extends core_js_1.Schema {
|
|
|
41
35
|
});
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
exports.IntersectionSchema = IntersectionSchema;
|
|
45
38
|
/**
|
|
46
39
|
* Creates an intersection schema combining fixed object properties with dynamic dictionary properties.
|
|
47
40
|
*
|
|
@@ -72,7 +65,7 @@ exports.IntersectionSchema = IntersectionSchema;
|
|
|
72
65
|
* ```
|
|
73
66
|
*/
|
|
74
67
|
/*@__NO_SIDE_EFFECTS__*/
|
|
75
|
-
function intersection(left, right) {
|
|
68
|
+
export function intersection(left, right) {
|
|
76
69
|
return new IntersectionSchema(left, right);
|
|
77
70
|
}
|
|
78
71
|
//# sourceMappingURL=intersection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../src/schema/intersection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../src/schema/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,GAGP,MAAM,YAAY,CAAA;AAyBnB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,kBAGX,SAAQ,MAGT;IAGC,YACqB,IAAU,EACV,KAAY;QAE/B,KAAK,EAAE,CAAA;QAHY,SAAI,GAAJ,IAAI,CAAM;QACV,UAAK,GAAL,KAAK,CAAO;QAJxB,SAAI,GAAG,cAAuB,CAAA;IAOvC,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE,OAAO,UAAU,CAAA;QAE1C,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;YACzD,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa;SACrC,CAAC,CAAA;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAwB;AACxB,MAAM,UAAU,YAAY,CAG1B,IAAU,EAAE,KAAY;IACxB,OAAO,IAAI,kBAAkB,CAAc,IAAI,EAAE,KAAK,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n Simplify,\n ValidationContext,\n} from '../core.js'\nimport { DictSchema } from './dict.js'\nimport { ObjectSchema } from './object.js'\n\n/**\n * Type utility for computing the intersection of two object types.\n *\n * Allows to more accurately represent the intersection of two object types\n * where both types may share some keys, and one of them uses an index\n * signature.\n *\n * @template A - First object type (typically from ObjectSchema)\n * @template B - Second object type (typically from DictSchema)\n *\n * @see {@link https://www.typescriptlang.org/play/?#code/C4TwDgpgBAglC8UDeUBmB7dAuKByARgIYBOuUAvlAGTJQDaA+lAJYB2UAzsMWwOYC6OVgFcAtvgjEKAKGkATCAGMANiWiL0rLlEI4YsjVuBQA1hBA4uPVrwRQARBnT2Dm7QDdCy4dESE6ZiD8UAD0IVAi4pJQABQcABbowspyUBIORMT2AJSyEAAeYOjExqCQUACSrMCSHErAzJoAPNJQsFAFNaxyHFAASkrFck1WfAA0UMKsJqzoAO6sAHxjrVAAQh35XT39g8TDozYTUzPzSyuLdqtwVKttMYHoqO00j88bnRDdvawQ7pJ3NpQAD860BbRwSHBQLadAA0ix2G91oJ1vDggAfWABcxPF5QOH8aFtci5aRlaAwVDMfIQVKIKo1Yh1RQNZq0Jw4AgkMjkCYoRiIzjcPioyISKTkRayBQqNRQQzaQgAMRpdL01NpclcRignm8EFVWrsKrVchxQVC4XF0SxmSAA Playground link}\n */\nexport type Intersect<A, B> = B[keyof B] extends never\n ? A\n : keyof A & keyof B extends never\n ? // If A and B don't overlap, just return A & B\n A & B\n : // Otherwise, properly represent the fact that accessing using an\n // index signature could return a value from either A or B\n A & { [K in keyof B]: B[K] | A[keyof A & K] }\n\n/**\n * Schema for combining an object schema with a dictionary schema.\n *\n * Validates that the input matches both the fixed object shape and allows\n * additional properties that match the dictionary schema. Properties defined\n * in the object schema are validated by the object, and remaining properties\n * are validated by the dictionary.\n *\n * @template Left - The ObjectSchema type for fixed properties\n * @template Right - The DictSchema type for additional properties\n *\n * @example\n * ```ts\n * const schema = new IntersectionSchema(\n * l.object({ name: l.string() }),\n * l.dict(l.string(), l.integer())\n * )\n * // Validates: { name: 'test', score: 100, count: 5 }\n * ```\n */\nexport class IntersectionSchema<\n const Left extends ObjectSchema = any,\n const Right extends DictSchema = any,\n> extends Schema<\n Simplify<Intersect<InferInput<Left>, InferInput<Right>>>,\n Simplify<Intersect<InferOutput<Left>, InferOutput<Right>>>\n> {\n readonly type = 'intersection' as const\n\n constructor(\n protected readonly left: Left,\n protected readonly right: Right,\n ) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n const leftResult = ctx.validate(input, this.left)\n if (!leftResult.success) return leftResult\n\n return this.right.validateInContext(leftResult.value, ctx, {\n ignoredKeys: this.left.validatorsMap,\n })\n }\n}\n\n/**\n * Creates an intersection schema combining fixed object properties with dynamic dictionary properties.\n *\n * Useful for objects that have a known set of properties plus additional\n * arbitrary properties that follow a pattern.\n *\n * @param left - Object schema defining the fixed, known properties\n * @param right - Dictionary schema for validating additional properties\n * @returns A new {@link IntersectionSchema} instance\n *\n * @example\n * ```ts\n * // Object with fixed and dynamic properties\n * const configSchema = l.intersection(\n * l.object({\n * version: l.integer(),\n * name: l.string(),\n * }),\n * l.dict(l.string(), l.string()) // Additional string properties\n * )\n *\n * configSchema.parse({\n * version: 1,\n * name: 'my-config',\n * customField: 'value',\n * anotherField: 'another',\n * })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function intersection<\n const Left extends ObjectSchema,\n const Right extends DictSchema,\n>(left: Left, right: Right) {\n return new IntersectionSchema<Left, Right>(left, right)\n}\n"]}
|
package/dist/schema/lex-map.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
7
|
-
const lex_value_js_1 = require("./lex-value.js");
|
|
8
|
-
const propertyValueSchema = /*#__PURE__*/ (0, lex_value_js_1.lexValue)();
|
|
1
|
+
import { isPlainObject } from '@atproto/lex-data';
|
|
2
|
+
import { Schema } from '../core.js';
|
|
3
|
+
import { memoizedOptions } from '../util/memoize.js';
|
|
4
|
+
import { lexValue } from './lex-value.js';
|
|
5
|
+
const propertyValueSchema = /*#__PURE__*/ lexValue();
|
|
9
6
|
/**
|
|
10
7
|
* AT Protocol lexicon schema definitions with "type": "unknown" are represented
|
|
11
8
|
* as plain objects with string keys and values that are valid AT Protocol data
|
|
@@ -13,10 +10,13 @@ const propertyValueSchema = /*#__PURE__*/ (0, lex_value_js_1.lexValue)();
|
|
|
13
10
|
* type alias corresponds to the expected structure of such "unknown" schema
|
|
14
11
|
* values.
|
|
15
12
|
*/
|
|
16
|
-
class LexMapSchema extends
|
|
17
|
-
|
|
13
|
+
export class LexMapSchema extends Schema {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.type = 'lexMap';
|
|
17
|
+
}
|
|
18
18
|
validateInContext(input, ctx) {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isPlainObject(input)) {
|
|
20
20
|
return ctx.issueUnexpectedType(input, 'object');
|
|
21
21
|
}
|
|
22
22
|
for (const key of Object.keys(input)) {
|
|
@@ -32,7 +32,6 @@ class LexMapSchema extends core_js_1.Schema {
|
|
|
32
32
|
return ctx.success(input);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
exports.LexMapSchema = LexMapSchema;
|
|
36
35
|
/**
|
|
37
36
|
* Creates a schema that accepts any plain object with string keys and values
|
|
38
37
|
* that are valid AT Protocol data types (string, integer, boolean, null, bytes,
|
|
@@ -52,9 +51,9 @@ exports.LexMapSchema = LexMapSchema;
|
|
|
52
51
|
* schema.validate({ foo: 1.2 }) // fails - 1.2 is not a valid LexValue (not an integer)
|
|
53
52
|
* ```
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
export const lexMap = /*#__PURE__*/ memoizedOptions(function () {
|
|
56
55
|
return new LexMapSchema();
|
|
57
56
|
});
|
|
58
57
|
/** @deprecated Use {@link lexMap} instead */
|
|
59
|
-
|
|
58
|
+
export const unknownObject = lexMap;
|
|
60
59
|
//# sourceMappingURL=lex-map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lex-map.js","sourceRoot":"","sources":["../../src/schema/lex-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lex-map.js","sourceRoot":"","sources":["../../src/schema/lex-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,mBAAmB,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAA;AAIpD;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAc;IAAhD;;QACW,SAAI,GAAG,QAAiB,CAAA;IAmBnC,CAAC;IAjBC,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,oEAAoE;YACpE,qEAAqE;YACrE,wEAAwE;YACxE,0EAA0E;YAC1E,SAAS;YACT,MAAM,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAA,CAAC,sCAAsC;YACnG,IAAI,CAAC,CAAC,CAAC,OAAO;gBAAE,OAAO,CAAC,CAAA;QAC1B,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,eAAe,CAAC;IAClD,OAAO,IAAI,YAAY,EAAE,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA","sourcesContent":["import { LexMap, isPlainObject } from '@atproto/lex-data'\nimport { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\nimport { lexValue } from './lex-value.js'\n\nconst propertyValueSchema = /*#__PURE__*/ lexValue()\n\nexport type { LexMap }\n\n/**\n * AT Protocol lexicon schema definitions with \"type\": \"unknown\" are represented\n * as plain objects with string keys and values that are valid AT Protocol data\n * types (string, integer, boolean, null, bytes, cid, array, or object). This\n * type alias corresponds to the expected structure of such \"unknown\" schema\n * values.\n */\nexport class LexMapSchema extends Schema<LexMap> {\n readonly type = 'lexMap' as const\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (!isPlainObject(input)) {\n return ctx.issueUnexpectedType(input, 'object')\n }\n\n for (const key of Object.keys(input)) {\n // @NOTE We use a lexValue() schema here to recursively validate all\n // nested values, which ensures that the error reporting includes the\n // correct path and type information for any invalid nested values. This\n // allows for more informative error descriptions than a simple \"isLexMap\"\n // check.\n const r = ctx.validateChild(input, key, propertyValueSchema) // recursively validate all properties\n if (!r.success) return r\n }\n\n return ctx.success(input)\n }\n}\n\n/**\n * Creates a schema that accepts any plain object with string keys and values\n * that are valid AT Protocol data types (string, integer, boolean, null, bytes,\n * cid, array, or object).\n *\n * @see {@link LexMap} from `@atproto/lex-data` for the type definition of valid AT Protocol data types\n * @returns A new {@link LexMapSchema} instance\n *\n * @example\n * ```ts\n * // Accept any object shape\n * const schema = l.lexMap()\n *\n * schema.validate({ any: 'props' }) // success\n * schema.validate([1, 2, 3]) // fails - only plain objects are accepted\n * schema.validate({ foo: new Date() }) // fails - Date is not a valid LexValue\n * schema.validate({ foo: 1.2 }) // fails - 1.2 is not a valid LexValue (not an integer)\n * ```\n */\nexport const lexMap = /*#__PURE__*/ memoizedOptions(function () {\n return new LexMapSchema()\n})\n\n/** @deprecated Use {@link lexMap} instead */\nexport const unknownObject = lexMap\n"]}
|
package/dist/schema/lex-value.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const lex_data_1 = require("@atproto/lex-data");
|
|
5
|
-
const core_js_1 = require("../core.js");
|
|
6
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
1
|
+
import { isLexScalar, isPlainObject } from '@atproto/lex-data';
|
|
2
|
+
import { Schema } from '../core.js';
|
|
3
|
+
import { memoizedOptions } from '../util/memoize.js';
|
|
7
4
|
const EXPECTED_TYPES = Object.freeze([
|
|
8
5
|
// Scalar types
|
|
9
6
|
'null',
|
|
@@ -20,8 +17,11 @@ const EXPECTED_TYPES = Object.freeze([
|
|
|
20
17
|
* AT Protocol lexicon values are any valid AT Protocol data types: string,
|
|
21
18
|
* integer, boolean, null, bytes, cid, array, or object.
|
|
22
19
|
*/
|
|
23
|
-
class LexValueSchema extends
|
|
24
|
-
|
|
20
|
+
export class LexValueSchema extends Schema {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.type = 'lexValue';
|
|
24
|
+
}
|
|
25
25
|
validateInContext(input, ctx) {
|
|
26
26
|
// @NOTE We are *not* using "isLexValue" here to allow for more specific
|
|
27
27
|
// error messages about the path and type of the invalid value. The
|
|
@@ -38,7 +38,7 @@ class LexValueSchema extends core_js_1.Schema {
|
|
|
38
38
|
// recursion depth limits in JavaScript. However, this is also not a
|
|
39
39
|
// concern for most valid input, as extremely deep nesting is unlikely in
|
|
40
40
|
// typical use cases.
|
|
41
|
-
if (
|
|
41
|
+
if (isPlainObject(input)) {
|
|
42
42
|
for (const key of Object.keys(input)) {
|
|
43
43
|
const r = ctx.validateChild(input, key, this); // recursively validate all properties
|
|
44
44
|
if (!r.success)
|
|
@@ -52,13 +52,12 @@ class LexValueSchema extends core_js_1.Schema {
|
|
|
52
52
|
return r;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
else if (!
|
|
55
|
+
else if (!isLexScalar(input)) {
|
|
56
56
|
return ctx.issueInvalidType(input, EXPECTED_TYPES);
|
|
57
57
|
}
|
|
58
58
|
return ctx.success(input);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
exports.LexValueSchema = LexValueSchema;
|
|
62
61
|
/**
|
|
63
62
|
* Creates a schema that accepts any valid AT Protocol data type: string,
|
|
64
63
|
* integer, boolean, null, bytes, cid, array, or plain object. Arrays and
|
|
@@ -81,7 +80,7 @@ exports.LexValueSchema = LexValueSchema;
|
|
|
81
80
|
* schema.validate({ foo: 1.2 }) // fails - 1.2 is not a valid LexValue (not an integer)
|
|
82
81
|
* ```
|
|
83
82
|
*/
|
|
84
|
-
|
|
83
|
+
export const lexValue = /*#__PURE__*/ memoizedOptions(function () {
|
|
85
84
|
return new LexValueSchema();
|
|
86
85
|
});
|
|
87
86
|
//# sourceMappingURL=lex-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lex-value.js","sourceRoot":"","sources":["../../src/schema/lex-value.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lex-value.js","sourceRoot":"","sources":["../../src/schema/lex-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAIpD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,eAAe;IACf,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,KAAK;IACL,OAAO;IACP,kBAAkB;IAClB,OAAO;IACP,QAAQ;CACA,CAAC,CAAA;AAEX;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAgB;IAApD;;QACW,SAAI,GAAG,UAAmB,CAAA;IAmCrC,CAAC;IAjCC,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,wEAAwE;QACxE,mEAAmE;QACnE,0EAA0E;QAC1E,6BAA6B;QAE7B,oEAAoE;QACpE,qBAAqB;QACrB,4EAA4E;QAC5E,0EAA0E;QAC1E,4EAA4E;QAC5E,wEAAwE;QACxE,gCAAgC;QAChC,4EAA4E;QAC5E,uEAAuE;QACvE,4EAA4E;QAC5E,wBAAwB;QACxB,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrC,MAAM,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA,CAAC,sCAAsC;gBACpF,IAAI,CAAC,CAAC,CAAC,OAAO;oBAAE,OAAO,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA,CAAC,uCAAuC;gBACnF,IAAI,CAAC,CAAC,CAAC,OAAO;oBAAE,OAAO,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAAC;IACpD,OAAO,IAAI,cAAc,EAAE,CAAA;AAC7B,CAAC,CAAC,CAAA","sourcesContent":["import { LexValue, isLexScalar, isPlainObject } from '@atproto/lex-data'\nimport { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\nexport type { LexValue }\n\nconst EXPECTED_TYPES = Object.freeze([\n // Scalar types\n 'null',\n 'boolean',\n 'integer',\n 'string',\n 'cid',\n 'bytes',\n // Recursive types\n 'array',\n 'object',\n] as const)\n\n/**\n * AT Protocol lexicon values are any valid AT Protocol data types: string,\n * integer, boolean, null, bytes, cid, array, or object.\n */\nexport class LexValueSchema extends Schema<LexValue> {\n readonly type = 'lexValue' as const\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n // @NOTE We are *not* using \"isLexValue\" here to allow for more specific\n // error messages about the path and type of the invalid value. The\n // \"isLexValue\" check is effectively performed by the recursive validation\n // of child properties below.\n\n // @NOTE There are two limitations to the fact that we are not using\n // \"isLexValue\" here:\n // 1. We cannot detect circular references in objects or arrays, which would\n // cause infinite recursion. However, circular references are not valid\n // AT Protocol data types, so this is not a concern for valid input. This\n // could easily be addressed in the \"validateChild\" method by keeping\n // track of \"parent\" objects.\n // 2. We are limited in the recursion depth we can validate due to potential\n // recursion depth limits in JavaScript. However, this is also not a\n // concern for most valid input, as extremely deep nesting is unlikely in\n // typical use cases.\n if (isPlainObject(input)) {\n for (const key of Object.keys(input)) {\n const r = ctx.validateChild(input, key, this) // recursively validate all properties\n if (!r.success) return r\n }\n } else if (Array.isArray(input)) {\n for (let i = 0; i < input.length; i++) {\n const r = ctx.validateChild(input, i, this) // recursively validate all array items\n if (!r.success) return r\n }\n } else if (!isLexScalar(input)) {\n return ctx.issueInvalidType(input, EXPECTED_TYPES)\n }\n\n return ctx.success(input)\n }\n}\n\n/**\n * Creates a schema that accepts any valid AT Protocol data type: string,\n * integer, boolean, null, bytes, cid, array, or plain object. Arrays and\n * objects are recursively validated to ensure all nested values are also valid\n * AT Protocol data types.\n *\n * @see {@link LexValue} from `@atproto/lex-data` for the type definition of valid AT Protocol data types\n * @returns A new {@link LexValueSchema} instance\n *\n * @example\n * ```ts\n * const schema = l.lexValue()\n *\n * schema.validate('hello') // success\n * schema.validate(42) // success\n * schema.validate(null) // success\n * schema.validate([1, 'two', null]) // success\n * schema.validate({ any: 'props' }) // success\n * schema.validate(new Date()) // fails - Date is not a valid LexValue\n * schema.validate({ foo: 1.2 }) // fails - 1.2 is not a valid LexValue (not an integer)\n * ```\n */\nexport const lexValue = /*#__PURE__*/ memoizedOptions(function () {\n return new LexValueSchema()\n})\n"]}
|
package/dist/schema/literal.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LiteralSchema = void 0;
|
|
4
|
-
exports.literal = literal;
|
|
5
|
-
const core_js_1 = require("../core.js");
|
|
1
|
+
import { Schema } from '../core.js';
|
|
6
2
|
/**
|
|
7
3
|
* Schema that only accepts a specific literal value.
|
|
8
4
|
*
|
|
@@ -18,12 +14,11 @@ const core_js_1 = require("../core.js");
|
|
|
18
14
|
* schema.validate('user') // fails
|
|
19
15
|
* ```
|
|
20
16
|
*/
|
|
21
|
-
class LiteralSchema extends
|
|
22
|
-
value;
|
|
23
|
-
type = 'literal';
|
|
17
|
+
export class LiteralSchema extends Schema {
|
|
24
18
|
constructor(value) {
|
|
25
19
|
super();
|
|
26
20
|
this.value = value;
|
|
21
|
+
this.type = 'literal';
|
|
27
22
|
}
|
|
28
23
|
validateInContext(input, ctx) {
|
|
29
24
|
if (input !== this.value) {
|
|
@@ -32,7 +27,6 @@ class LiteralSchema extends core_js_1.Schema {
|
|
|
32
27
|
return ctx.success(this.value);
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
|
-
exports.LiteralSchema = LiteralSchema;
|
|
36
30
|
/**
|
|
37
31
|
* Creates a literal schema that only accepts the exact specified value.
|
|
38
32
|
*
|
|
@@ -63,7 +57,7 @@ exports.LiteralSchema = LiteralSchema;
|
|
|
63
57
|
* ```
|
|
64
58
|
*/
|
|
65
59
|
/*@__NO_SIDE_EFFECTS__*/
|
|
66
|
-
function literal(value) {
|
|
60
|
+
export function literal(value) {
|
|
67
61
|
return new LiteralSchema(value);
|
|
68
62
|
}
|
|
69
63
|
//# sourceMappingURL=literal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal.js","sourceRoot":"","sources":["../../src/schema/literal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"literal.js","sourceRoot":"","sources":["../../src/schema/literal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AAEtD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,aAEX,SAAQ,MAAc;IAGtB,YAAqB,KAAa;QAChC,KAAK,EAAE,CAAA;QADY,UAAK,GAAL,KAAK,CAAQ;QAFzB,SAAI,GAAG,SAAkB,CAAA;IAIlC,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAwB;AACxB,MAAM,UAAU,OAAO,CACrB,KAAQ;IAER,OAAO,IAAI,aAAa,CAAI,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\n\n/**\n * Schema that only accepts a specific literal value.\n *\n * Validates that the input is exactly equal to the specified value using\n * strict equality (===).\n *\n * @template TValue - The literal type (null, string, number, or boolean)\n *\n * @example\n * ```ts\n * const schema = new LiteralSchema('admin')\n * schema.validate('admin') // success\n * schema.validate('user') // fails\n * ```\n */\nexport class LiteralSchema<\n const TValue extends null | string | number | boolean,\n> extends Schema<TValue> {\n readonly type = 'literal' as const\n\n constructor(readonly value: TValue) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (input !== this.value) {\n return ctx.issueInvalidValue(input, [this.value])\n }\n\n return ctx.success(this.value)\n }\n}\n\n/**\n * Creates a literal schema that only accepts the exact specified value.\n *\n * Useful for discriminator fields in unions, constant values, or type narrowing.\n *\n * @param value - The exact value that must be matched\n * @returns A new {@link LiteralSchema} instance\n *\n * @example\n * ```ts\n * // String literal\n * const roleSchema = l.literal('admin')\n *\n * // Number literal\n * const versionSchema = l.literal(1)\n *\n * // Boolean literal\n * const enabledSchema = l.literal(true)\n *\n * // Null literal\n * const nullSchema = l.literal(null)\n *\n * // In discriminated unions\n * const actionSchema = l.discriminatedUnion('type', [\n * l.object({ type: l.literal('create'), data: l.unknown() }),\n * l.object({ type: l.literal('delete'), id: l.string() }),\n * ])\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function literal<const V extends null | string | number | boolean>(\n value: V,\n) {\n return new LiteralSchema<V>(value)\n}\n"]}
|
package/dist/schema/never.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.never = exports.NeverSchema = void 0;
|
|
4
|
-
const core_js_1 = require("../core.js");
|
|
5
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
1
|
+
import { Schema } from '../core.js';
|
|
2
|
+
import { memoizedOptions } from '../util/memoize.js';
|
|
6
3
|
/**
|
|
7
4
|
* Schema that always fails validation.
|
|
8
5
|
*
|
|
@@ -15,13 +12,15 @@ const memoize_js_1 = require("../util/memoize.js");
|
|
|
15
12
|
* schema.validate(anything) // always fails
|
|
16
13
|
* ```
|
|
17
14
|
*/
|
|
18
|
-
class NeverSchema extends
|
|
19
|
-
|
|
15
|
+
export class NeverSchema extends Schema {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.type = 'never';
|
|
19
|
+
}
|
|
20
20
|
validateInContext(input, ctx) {
|
|
21
21
|
return ctx.issueUnexpectedType(input, 'never');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
exports.NeverSchema = NeverSchema;
|
|
25
24
|
/**
|
|
26
25
|
* Creates a never schema that always fails validation.
|
|
27
26
|
*
|
|
@@ -52,7 +51,7 @@ exports.NeverSchema = NeverSchema;
|
|
|
52
51
|
* })
|
|
53
52
|
* ```
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
export const never = /*#__PURE__*/ memoizedOptions(function () {
|
|
56
55
|
return new NeverSchema();
|
|
57
56
|
});
|
|
58
57
|
//# sourceMappingURL=never.js.map
|
package/dist/schema/never.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/schema/never.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/schema/never.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAa;IAA9C;;QACW,SAAI,GAAG,OAAgB,CAAA;IAKlC,CAAC;IAHC,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAChD,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,eAAe,CAAC;IACjD,OAAO,IAAI,WAAW,EAAE,CAAA;AAC1B,CAAC,CAAC,CAAA","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\n/**\n * Schema that always fails validation.\n *\n * Represents an impossible type - no value can satisfy this schema.\n * Useful for exhaustiveness checking or marking impossible branches.\n *\n * @example\n * ```ts\n * const schema = new NeverSchema()\n * schema.validate(anything) // always fails\n * ```\n */\nexport class NeverSchema extends Schema<never> {\n readonly type = 'never' as const\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n return ctx.issueUnexpectedType(input, 'never')\n }\n}\n\n/**\n * Creates a never schema that always fails validation.\n *\n * Useful for exhaustiveness checking in TypeScript or marking impossible\n * code paths.\n *\n * @returns A new {@link NeverSchema} instance\n *\n * @example\n * ```ts\n * // Exhaustiveness checking\n * type Status = 'active' | 'inactive'\n *\n * function handleStatus(status: Status) {\n * switch (status) {\n * case 'active': return 'Active'\n * case 'inactive': return 'Inactive'\n * default:\n * // TypeScript will error if we miss a case\n * l.never().parse(status)\n * }\n * }\n *\n * // In impossible union branches\n * const schema = l.object({\n * type: l.literal('fixed'),\n * dynamic: l.never(), // This property can never exist\n * })\n * ```\n */\nexport const never = /*#__PURE__*/ memoizedOptions(function () {\n return new NeverSchema()\n})\n"]}
|
package/dist/schema/null.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.null = exports.nullSchema = exports.NullSchema = void 0;
|
|
4
|
-
const core_js_1 = require("../core.js");
|
|
5
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
1
|
+
import { Schema } from '../core.js';
|
|
2
|
+
import { memoizedOptions } from '../util/memoize.js';
|
|
6
3
|
/**
|
|
7
4
|
* Schema for validating null values.
|
|
8
5
|
*
|
|
@@ -16,8 +13,11 @@ const memoize_js_1 = require("../util/memoize.js");
|
|
|
16
13
|
* schema.validate(undefined) // fails
|
|
17
14
|
* ```
|
|
18
15
|
*/
|
|
19
|
-
class NullSchema extends
|
|
20
|
-
|
|
16
|
+
export class NullSchema extends Schema {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.type = 'null';
|
|
20
|
+
}
|
|
21
21
|
validateInContext(input, ctx) {
|
|
22
22
|
if (input !== null) {
|
|
23
23
|
return ctx.issueUnexpectedType(input, 'null');
|
|
@@ -25,7 +25,6 @@ class NullSchema extends core_js_1.Schema {
|
|
|
25
25
|
return ctx.success(null);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
exports.NullSchema = NullSchema;
|
|
29
28
|
/**
|
|
30
29
|
* Creates a null schema that only accepts the null value.
|
|
31
30
|
*
|
|
@@ -42,8 +41,8 @@ exports.NullSchema = NullSchema;
|
|
|
42
41
|
* const nullableStringSchema = l.union([l.string(), l.null()])
|
|
43
42
|
* ```
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
export const nullSchema = /*#__PURE__*/ memoizedOptions(function () {
|
|
46
45
|
return new NullSchema();
|
|
47
46
|
});
|
|
48
|
-
|
|
47
|
+
export { nullSchema as null };
|
|
49
48
|
//# sourceMappingURL=null.js.map
|
package/dist/schema/null.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null.js","sourceRoot":"","sources":["../../src/schema/null.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"null.js","sourceRoot":"","sources":["../../src/schema/null.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAY;IAA5C;;QACW,SAAI,GAAG,MAAe,CAAA;IASjC,CAAC;IAPC,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC/C,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,eAAe,CAAC;IACtD,OAAO,IAAI,UAAU,EAAE,CAAA;AACzB,CAAC,CAAC,CAAA;AAEF,OAAO,EAAE,UAAU,IAAI,IAAI,EAAE,CAAA","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\n/**\n * Schema for validating null values.\n *\n * Only accepts the JavaScript `null` value. Rejects `undefined` and all\n * other values.\n *\n * @example\n * ```ts\n * const schema = new NullSchema()\n * schema.validate(null) // success\n * schema.validate(undefined) // fails\n * ```\n */\nexport class NullSchema extends Schema<null> {\n readonly type = 'null' as const\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (input !== null) {\n return ctx.issueUnexpectedType(input, 'null')\n }\n\n return ctx.success(null)\n }\n}\n\n/**\n * Creates a null schema that only accepts the null value.\n *\n * Useful for explicitly representing null in union types or optional fields.\n *\n * @returns A new {@link NullSchema} instance\n *\n * @example\n * ```ts\n * // Explicit null\n * const nullOnlySchema = l.null()\n *\n * // Nullable string (string or null)\n * const nullableStringSchema = l.union([l.string(), l.null()])\n * ```\n */\nexport const nullSchema = /*#__PURE__*/ memoizedOptions(function () {\n return new NullSchema()\n})\n\nexport { nullSchema as null }\n"]}
|
package/dist/schema/nullable.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.nullable = exports.NullableSchema = void 0;
|
|
4
|
-
const core_js_1 = require("../core.js");
|
|
5
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
1
|
+
import { Schema, } from '../core.js';
|
|
2
|
+
import { memoizedTransformer } from '../util/memoize.js';
|
|
6
3
|
/**
|
|
7
4
|
* Schema wrapper that allows null values in addition to the wrapped schema.
|
|
8
5
|
*
|
|
@@ -18,12 +15,11 @@ const memoize_js_1 = require("../util/memoize.js");
|
|
|
18
15
|
* schema.validate('hello') // success
|
|
19
16
|
* ```
|
|
20
17
|
*/
|
|
21
|
-
class NullableSchema extends
|
|
22
|
-
validator;
|
|
23
|
-
type = 'nullable';
|
|
18
|
+
export class NullableSchema extends Schema {
|
|
24
19
|
constructor(validator) {
|
|
25
20
|
super();
|
|
26
21
|
this.validator = validator;
|
|
22
|
+
this.type = 'nullable';
|
|
27
23
|
}
|
|
28
24
|
validateInContext(input, ctx) {
|
|
29
25
|
if (input === null) {
|
|
@@ -32,7 +28,6 @@ class NullableSchema extends core_js_1.Schema {
|
|
|
32
28
|
return ctx.validate(input, this.validator);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
|
-
exports.NullableSchema = NullableSchema;
|
|
36
31
|
/**
|
|
37
32
|
* Creates a nullable schema that accepts null in addition to the wrapped type.
|
|
38
33
|
*
|
|
@@ -59,7 +54,7 @@ exports.NullableSchema = NullableSchema;
|
|
|
59
54
|
* const maybeString = l.optional(l.nullable(l.string()))
|
|
60
55
|
* ```
|
|
61
56
|
*/
|
|
62
|
-
|
|
57
|
+
export const nullable = /*#__PURE__*/ memoizedTransformer(function (validator) {
|
|
63
58
|
return new NullableSchema(validator);
|
|
64
59
|
});
|
|
65
60
|
//# sourceMappingURL=nullable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../src/schema/nullable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../src/schema/nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,GAGP,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAmD,SAAQ,MAGvE;IAGC,YAAqB,SAAqB;QACxC,KAAK,EAAE,CAAA;QADY,cAAS,GAAT,SAAS,CAAY;QAFjC,SAAI,GAAG,UAAmB,CAAA;IAInC,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC;QAED,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAC5C,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,UAExD,SAAqB;IACrB,OAAO,IAAI,cAAc,CAAa,SAAS,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n} from '../core.js'\nimport { memoizedTransformer } from '../util/memoize.js'\n\n/**\n * Schema wrapper that allows null values in addition to the wrapped schema.\n *\n * When the input is `null`, validation succeeds immediately. Otherwise,\n * the input is validated against the wrapped schema.\n *\n * @template TValidator - The wrapped validator type\n *\n * @example\n * ```ts\n * const schema = new NullableSchema(l.string())\n * schema.validate(null) // success\n * schema.validate('hello') // success\n * ```\n */\nexport class NullableSchema<const TValidator extends Validator> extends Schema<\n InferInput<TValidator> | null,\n InferOutput<TValidator> | null\n> {\n readonly type = 'nullable' as const\n\n constructor(readonly validator: TValidator) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (input === null) {\n return ctx.success(null)\n }\n\n return ctx.validate(input, this.validator)\n }\n}\n\n/**\n * Creates a nullable schema that accepts null in addition to the wrapped type.\n *\n * Wraps another schema to allow null values. Different from `optional()` which\n * allows undefined.\n *\n * @param validator - The validator to make nullable\n * @returns A new {@link NullableSchema} instance\n *\n * @example\n * ```ts\n * // Nullable string\n * const nullableString = l.nullable(l.string())\n * nullableString.parse(null) // null\n * nullableString.parse('hello') // 'hello'\n *\n * // In an object\n * const userSchema = l.object({\n * name: l.string(),\n * deletedAt: l.nullable(l.string({ format: 'datetime' })),\n * })\n *\n * // Combine with optional for null or undefined\n * const maybeString = l.optional(l.nullable(l.string()))\n * ```\n */\nexport const nullable = /*#__PURE__*/ memoizedTransformer(function <\n const TValidator extends Validator,\n>(validator: TValidator) {\n return new NullableSchema<TValidator>(validator)\n})\n"]}
|
package/dist/schema/object.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.object = object;
|
|
5
|
-
const lex_data_1 = require("@atproto/lex-data");
|
|
6
|
-
const core_js_1 = require("../core.js");
|
|
7
|
-
const lazy_property_js_1 = require("../util/lazy-property.js");
|
|
1
|
+
import { isPlainObject } from '@atproto/lex-data';
|
|
2
|
+
import { Schema, } from '../core.js';
|
|
3
|
+
import { lazyProperty } from '../util/lazy-property.js';
|
|
8
4
|
/**
|
|
9
5
|
* Schema for validating objects with a defined shape.
|
|
10
6
|
*
|
|
@@ -22,19 +18,18 @@ const lazy_property_js_1 = require("../util/lazy-property.js");
|
|
|
22
18
|
* const result = schema.validate({ name: 'Alice' })
|
|
23
19
|
* ```
|
|
24
20
|
*/
|
|
25
|
-
class ObjectSchema extends
|
|
26
|
-
shape;
|
|
27
|
-
type = 'object';
|
|
21
|
+
export class ObjectSchema extends Schema {
|
|
28
22
|
constructor(shape) {
|
|
29
23
|
super();
|
|
30
24
|
this.shape = shape;
|
|
25
|
+
this.type = 'object';
|
|
31
26
|
}
|
|
32
27
|
get validatorsMap() {
|
|
33
28
|
const map = new Map(Object.entries(this.shape));
|
|
34
|
-
return
|
|
29
|
+
return lazyProperty(this, 'validatorsMap', map);
|
|
35
30
|
}
|
|
36
31
|
validateInContext(input, ctx) {
|
|
37
|
-
if (!
|
|
32
|
+
if (!isPlainObject(input)) {
|
|
38
33
|
return ctx.issueUnexpectedType(input, 'object');
|
|
39
34
|
}
|
|
40
35
|
// Lazily copy value
|
|
@@ -64,7 +59,6 @@ class ObjectSchema extends core_js_1.Schema {
|
|
|
64
59
|
return ctx.success(copy ?? input);
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
|
-
exports.ObjectSchema = ObjectSchema;
|
|
68
62
|
/**
|
|
69
63
|
* Creates an object schema with the specified property validators.
|
|
70
64
|
*
|
|
@@ -100,7 +94,7 @@ exports.ObjectSchema = ObjectSchema;
|
|
|
100
94
|
* ```
|
|
101
95
|
*/
|
|
102
96
|
/*@__NO_SIDE_EFFECTS__*/
|
|
103
|
-
function object(properties) {
|
|
97
|
+
export function object(properties) {
|
|
104
98
|
return new ObjectSchema(properties);
|
|
105
99
|
}
|
|
106
100
|
//# sourceMappingURL=object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/schema/object.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/schema/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAGL,MAAM,GAIP,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AASvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,YAEX,SAAQ,MAOT;IAGC,YAAqB,KAAa;QAChC,KAAK,EAAE,CAAA;QADY,UAAK,GAAL,KAAK,CAAQ;QAFzB,SAAI,GAAG,QAAiB,CAAA;IAIjC,CAAC;IAED,IAAI,aAAa;QACf,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QAE/C,OAAO,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;QAED,oBAAoB;QACpB,IAAI,IAAyC,CAAA;QAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;YACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;oBACpB,sCAAsC;oBACtC,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;gBACzC,CAAC;gBAED,OAAO,MAAM,CAAA;YACf,CAAC;YAED,uEAAuE;YACvE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;gBAClD,SAAQ;YACV,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACzC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;oBACpC,sEAAsE;oBACtE,OAAO,GAAG,CAAC,yBAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;gBAClE,CAAC;gBAED,IAAI,KAAK,EAAE,GAAG,KAAK,EAAE,CAAA;gBACrB,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAA;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,CAAA;IACnC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAwB;AACxB,MAAM,UAAU,MAAM,CACpB,UAAkB;IAElB,OAAO,IAAI,YAAY,CAAS,UAAU,CAAC,CAAA;AAC7C,CAAC","sourcesContent":["import { isPlainObject } from '@atproto/lex-data'\nimport {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n WithOptionalProperties,\n} from '../core.js'\nimport { lazyProperty } from '../util/lazy-property.js'\n\n/**\n * Type representing the shape of an object schema.\n *\n * Maps property names to their corresponding validators.\n */\nexport type ObjectSchemaShape = Record<string, Validator>\n\n/**\n * Schema for validating objects with a defined shape.\n *\n * Each property in the shape is validated against its corresponding schema.\n * Properties wrapped in `optional()` are not required.\n *\n * @template TShape - The object shape type mapping property names to validators\n *\n * @example\n * ```ts\n * const schema = new ObjectSchema({\n * name: l.string(),\n * age: l.optional(l.integer()),\n * })\n * const result = schema.validate({ name: 'Alice' })\n * ```\n */\nexport class ObjectSchema<\n const TShape extends ObjectSchemaShape = any,\n> extends Schema<\n WithOptionalProperties<{\n [K in keyof TShape]: InferInput<TShape[K]>\n }>,\n WithOptionalProperties<{\n [K in keyof TShape]: InferOutput<TShape[K]>\n }>\n> {\n readonly type = 'object' as const\n\n constructor(readonly shape: TShape) {\n super()\n }\n\n get validatorsMap(): Map<string, Validator> {\n const map = new Map(Object.entries(this.shape))\n\n return lazyProperty(this, 'validatorsMap', map)\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (!isPlainObject(input)) {\n return ctx.issueUnexpectedType(input, 'object')\n }\n\n // Lazily copy value\n let copy: undefined | Record<string, unknown>\n\n for (const [key, propDef] of this.validatorsMap) {\n const result = ctx.validateChild(input, key, propDef)\n if (!result.success) {\n if (!(key in input)) {\n // Transform into \"required key\" issue\n return ctx.issueRequiredKey(input, key)\n }\n\n return result\n }\n\n // Skip copying if key is not present in input (and value is undefined)\n if (result.value === undefined && !(key in input)) {\n continue\n }\n\n if (!Object.is(result.value, input[key])) {\n if (ctx.options.mode === 'validate') {\n // In \"validate\" mode, we can't modify the input, so we issue an error\n return ctx.issueInvalidPropertyValue(input, key, [result.value])\n }\n\n copy ??= { ...input }\n copy[key] = result.value\n }\n }\n\n return ctx.success(copy ?? input)\n }\n}\n\n/**\n * Creates an object schema with the specified property validators.\n *\n * Validates that the input is a plain object and each property matches\n * its corresponding schema. Properties wrapped in `optional()` are not required.\n *\n * @param properties - Object mapping property names to their validators\n * @returns A new {@link ObjectSchema} instance\n *\n * @example\n * ```ts\n * // Basic object\n * const userSchema = l.object({\n * name: l.string(),\n * email: l.string({ format: 'uri' }),\n * })\n *\n * // With optional properties\n * const profileSchema = l.object({\n * displayName: l.string(),\n * bio: l.optional(l.string({ maxLength: 256 })),\n * avatar: l.optional(l.blob({ accept: ['image/*'] })),\n * })\n *\n * // Nested objects\n * const postSchema = l.object({\n * text: l.string(),\n * author: l.object({\n * did: l.string({ format: 'did' }),\n * handle: l.string({ format: 'handle' }),\n * }),\n * })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function object<const TShape extends ObjectSchemaShape>(\n properties: TShape,\n) {\n return new ObjectSchema<TShape>(properties)\n}\n"]}
|
package/dist/schema/optional.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.optional = exports.OptionalSchema = void 0;
|
|
4
|
-
const core_js_1 = require("../core.js");
|
|
5
|
-
const memoize_js_1 = require("../util/memoize.js");
|
|
1
|
+
import { Schema, } from '../core.js';
|
|
2
|
+
import { memoizedTransformer } from '../util/memoize.js';
|
|
6
3
|
/**
|
|
7
4
|
* Schema wrapper that makes a value optional (allows undefined).
|
|
8
5
|
*
|
|
@@ -19,12 +16,11 @@ const memoize_js_1 = require("../util/memoize.js");
|
|
|
19
16
|
* schema.validate('hello') // success
|
|
20
17
|
* ```
|
|
21
18
|
*/
|
|
22
|
-
class OptionalSchema extends
|
|
23
|
-
validator;
|
|
24
|
-
type = 'optional';
|
|
19
|
+
export class OptionalSchema extends Schema {
|
|
25
20
|
constructor(validator) {
|
|
26
21
|
super();
|
|
27
22
|
this.validator = validator;
|
|
23
|
+
this.type = 'optional';
|
|
28
24
|
}
|
|
29
25
|
validateInContext(input, ctx) {
|
|
30
26
|
// Optimization: No need to apply child schema defaults in validation mode
|
|
@@ -43,7 +39,6 @@ class OptionalSchema extends core_js_1.Schema {
|
|
|
43
39
|
return result;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
|
-
exports.OptionalSchema = OptionalSchema;
|
|
47
42
|
/**
|
|
48
43
|
* Creates an optional schema that allows undefined values.
|
|
49
44
|
*
|
|
@@ -70,7 +65,7 @@ exports.OptionalSchema = OptionalSchema;
|
|
|
70
65
|
* countSchema.parse(undefined) // Returns 0
|
|
71
66
|
* ```
|
|
72
67
|
*/
|
|
73
|
-
|
|
68
|
+
export const optional = /*#__PURE__*/ memoizedTransformer(function (validator) {
|
|
74
69
|
return new OptionalSchema(validator);
|
|
75
70
|
});
|
|
76
71
|
//# sourceMappingURL=optional.js.map
|