@uniflowed/validator 0.34.0 → 0.36.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/action.js CHANGED
@@ -81,7 +81,7 @@ export function length(value: number): Step<string, string> {
81
81
  export function nonEmpty(): Step<string, string> {
82
82
  return <TInput>(schema: Schema<string, TInput>): Schema<string, TInput> =>
83
83
  refine(schema, (input: string) => input.length > 0, "non_empty", "expected a value", {
84
- kind: "minLength",
84
+ kind : "minLength",
85
85
  value: 1,
86
86
  });
87
87
  }
package/collection.js CHANGED
@@ -111,7 +111,7 @@ export function tuple<TItems extends Options>(
111
111
  const arity = items.length;
112
112
  const message = `expected ${String(arity)} tuple items`;
113
113
  const description = (): Description => ({
114
- kind: "tuple",
114
+ kind : "tuple",
115
115
  items: items.map((item) => describe(item)),
116
116
  });
117
117
 
@@ -220,12 +220,12 @@ export function record<TOutput, TInput>(
220
220
  * halfway through.
221
221
  */
222
222
  export function map<TKey, TKeyInput, TValue, TValueInput>(
223
- key: Schema<TKey, TKeyInput>,
223
+ key : Schema<TKey, TKeyInput>,
224
224
  value: Schema<TValue, TValueInput>,
225
225
  ): Schema<$ReadOnlyMap<TKey, TValue>, $ReadOnlyMap<TKeyInput, TValueInput>> {
226
226
  const description = (): Description => ({
227
- kind: "map",
228
- key: describe(key),
227
+ kind : "map",
228
+ key : describe(key),
229
229
  value: describe(value),
230
230
  });
231
231
 
@@ -298,9 +298,9 @@ export function set<TOutput, TInput>(
298
298
  }
299
299
  const collected = await collectAsync(
300
300
  Array.from(value).map((member, index) => ({
301
- keys: [String(index)],
301
+ keys : [String(index)],
302
302
  schema: item,
303
- value: member,
303
+ value : member,
304
304
  })),
305
305
  path,
306
306
  );
package/issue.js CHANGED
@@ -51,9 +51,9 @@ export type PathBuffer = Array<string>;
51
51
  * with one fewer field is one fewer allocation on the path that matters.
52
52
  */
53
53
  export type Issue = {|
54
- readonly code: string,
54
+ readonly code : string,
55
55
  readonly message: string,
56
- readonly path?: Path,
56
+ readonly path? : Path,
57
57
  |};
58
58
 
59
59
  /**
@@ -103,7 +103,7 @@ export class ValidationError extends Error {
103
103
  * reaches this function as a path segment.
104
104
  */
105
105
  export type FlatIssues = {|
106
- readonly root: $ReadOnlyArray<string>,
106
+ readonly root : $ReadOnlyArray<string>,
107
107
  readonly nested: { readonly [string]: $ReadOnlyArray<string>, ... },
108
108
  |};
109
109
 
package/json-schema.js CHANGED
@@ -84,7 +84,7 @@ export type Unrepresentable = {|
84
84
 
85
85
  /** A JSON Schema document, and everything JSON Schema could not say. */
86
86
  export type JsonSchemaExport = {|
87
- readonly schema: JsonSchemaNode,
87
+ readonly schema : JsonSchemaNode,
88
88
  readonly unrepresentable: $ReadOnlyArray<Unrepresentable>,
89
89
  |};
90
90
 
@@ -113,13 +113,13 @@ function merge(left: JsonSchemaNode, right: JsonSchemaNode): JsonSchemaNode {
113
113
  */
114
114
  function mayBeAbsent(description: Description): boolean {
115
115
  return match (description) {
116
- {kind: "optional", inner: _} => true,
117
- {kind: "nullish", inner: _} => true,
118
- {kind: "default", inner: _} => true,
119
- {kind: "fallback", inner: _} => true,
116
+ {kind: "optional", inner: _} => true,
117
+ {kind: "nullish", inner: _} => true,
118
+ {kind: "default", inner: _} => true,
119
+ {kind: "fallback", inner: _} => true,
120
120
  {kind: "constrained", inner: const inner, constraint: _} => mayBeAbsent(inner),
121
- {kind: "transformed", inner: const inner} => mayBeAbsent(inner),
122
- _ => false,
121
+ {kind: "transformed", inner: const inner} => mayBeAbsent(inner),
122
+ _ => false,
123
123
  };
124
124
  }
125
125
 
@@ -132,9 +132,9 @@ function mayBeAbsent(description: Description): boolean {
132
132
  */
133
133
  function describesTransformedValue(description: Description): boolean {
134
134
  return match (description) {
135
- {kind: "transformed", inner: _} => true,
135
+ {kind: "transformed", inner: _} => true,
136
136
  {kind: "constrained", inner: const inner, constraint: _} => describesTransformedValue(inner),
137
- _ => false,
137
+ _ => false,
138
138
  };
139
139
  }
140
140
 
@@ -146,19 +146,19 @@ function labelFor(constraint: Constraint): string {
146
146
  /** The JSON Schema keywords one `pipe` step contributes, if any. */
147
147
  function keywordsFor(constraint: Constraint): JsonSchemaNode {
148
148
  return match (constraint) {
149
- {kind: "minLength", value: const value} => { minLength: value },
150
- {kind: "maxLength", value: const value} => { maxLength: value },
151
- {kind: "length", value: const value} => { minLength: value, maxLength: value },
152
- {kind: "minItems", value: const value} => { minItems: value },
153
- {kind: "maxItems", value: const value} => { maxItems: value },
154
- {kind: "min", value: const value} => { minimum: value },
155
- {kind: "max", value: const value} => { maximum: value },
156
- {kind: "integer"} => { type: "integer" },
149
+ {kind: "minLength", value: const value} => { minLength: value },
150
+ {kind: "maxLength", value: const value} => { maxLength: value },
151
+ {kind: "length", value: const value} => { minLength: value, maxLength: value },
152
+ {kind: "minItems", value: const value} => { minItems: value },
153
+ {kind: "maxItems", value: const value} => { maxItems: value },
154
+ {kind: "min", value: const value} => { minimum: value },
155
+ {kind: "max", value: const value} => { maximum: value },
156
+ {kind: "integer"} => { type: "integer" },
157
157
  {kind: "multipleOf", value: const value} => { multipleOf: value },
158
- {kind: "pattern", source: const source} => { pattern: source },
159
- {kind: "format", name: const name} => { format: name },
160
- {kind: "brand", name: const name} => { title: name },
161
- {kind: "opaque", label: _} => {},
158
+ {kind: "pattern", source: const source} => { pattern: source },
159
+ {kind: "format", name: const name} => { format: name },
160
+ {kind: "brand", name: const name} => { title: name },
161
+ {kind: "opaque", label: _} => {},
162
162
  };
163
163
  }
164
164
 
@@ -181,9 +181,9 @@ export function toJsonSchema(schema: Schema<mixed, mixed>): JsonSchemaExport {
181
181
  }
182
182
 
183
183
  function object(
184
- entries: $ReadOnlyArray<[string, Description]>,
184
+ entries : $ReadOnlyArray<[string, Description]>,
185
185
  unknownKeys: "strip" | "reject" | "keep",
186
- path: Path,
186
+ path : Path,
187
187
  ): JsonSchemaNode {
188
188
  const properties: { [string]: JsonSchemaNode, ... } = {};
189
189
  const required: Array<string> = [];
@@ -210,66 +210,66 @@ export function toJsonSchema(schema: Schema<mixed, mixed>): JsonSchemaExport {
210
210
 
211
211
  function convert(description: Description, path: Path): JsonSchemaNode {
212
212
  return match (description) {
213
- {kind: "unknown"} => {},
214
- {kind: "never"} => { not: {} },
215
- {kind: "string"} => { type: "string" },
216
- {kind: "number"} => { type: "number" },
217
- {kind: "boolean"} => { type: "boolean" },
218
- {kind: "null"} => { type: "null" },
219
- {kind: "bigint"} => unsupported("bigint", path),
220
- {kind: "undefined"} => unsupported("undefined", path),
221
- {kind: "date"} => unsupported("date", path),
222
- {kind: "instance", name: const name} => unsupported(`instance ${name}`, path),
223
- {kind: "custom", name: const name} => unsupported(`custom ${name}`, path),
224
- {kind: "map", key: _, value: _} => unsupported("map", path),
225
- {kind: "set", item: _} => unsupported("set", path),
226
- {kind: "literal", value: const value} => { const: value },
227
- {kind: "enum", values: const values} => { enum: values.slice() },
228
- {kind: "array", item: const item} =>
213
+ {kind: "unknown"} => {},
214
+ {kind: "never"} => { not: {} },
215
+ {kind: "string"} => { type: "string" },
216
+ {kind: "number"} => { type: "number" },
217
+ {kind: "boolean"} => { type: "boolean" },
218
+ {kind: "null"} => { type: "null" },
219
+ {kind: "bigint"} => unsupported("bigint", path),
220
+ {kind: "undefined"} => unsupported("undefined", path),
221
+ {kind: "date"} => unsupported("date", path),
222
+ {kind: "instance", name: const name} => unsupported(`instance ${name}`, path),
223
+ {kind: "custom", name: const name} => unsupported(`custom ${name}`, path),
224
+ {kind: "map", key: _, value: _} => unsupported("map", path),
225
+ {kind: "set", item: _} => unsupported("set", path),
226
+ {kind: "literal", value: const value} => { const: value },
227
+ {kind: "enum", values: const values} => { enum: values.slice() },
228
+ {kind: "array", item: const item} =>
229
229
  {
230
- type: "array",
230
+ type : "array",
231
231
  items: convert(item, path.concat("*")),
232
232
  },
233
- {kind: "tuple", items: const items} =>
233
+ {kind: "tuple", items: const items} =>
234
234
  {
235
- type: "array",
235
+ type : "array",
236
236
  prefixItems: items.map((item, index) => convert(item, path.concat(String(index)))),
237
- minItems: items.length,
238
- maxItems: items.length,
237
+ minItems : items.length,
238
+ maxItems : items.length,
239
239
  },
240
- {kind: "record", value: const value} =>
240
+ {kind: "record", value: const value} =>
241
241
  {
242
- type: "object",
242
+ type : "object",
243
243
  additionalProperties: convert(value, path.concat("*")),
244
244
  },
245
245
  {kind: "object", entries: const entries, unknownKeys: const unknownKeys} =>
246
246
  object(entries, unknownKeys, path),
247
- {kind: "union", options: const options} =>
247
+ {kind: "union", options: const options} =>
248
248
  {
249
249
  anyOf: options.map((option) => convert(option, path)),
250
250
  },
251
- {kind: "variant", key: _, branches: const branches} =>
251
+ {kind: "variant", key: _, branches: const branches} =>
252
252
  {
253
253
  oneOf: branches.map(([, branch]) => convert(branch, path)),
254
254
  },
255
- {kind: "intersect", parts: const parts} =>
255
+ {kind: "intersect", parts: const parts} =>
256
256
  {
257
257
  allOf: parts.map((part) => convert(part, path)),
258
258
  },
259
- {kind: "optional", inner: const inner} => convert(inner, path),
260
- {kind: "default", inner: const inner} => convert(inner, path),
261
- {kind: "nullable", inner: const inner} =>
259
+ {kind: "optional", inner: const inner} => convert(inner, path),
260
+ {kind: "default", inner: const inner} => convert(inner, path),
261
+ {kind: "nullable", inner: const inner} =>
262
262
  {
263
263
  anyOf: [convert(inner, path), { type: "null" }],
264
264
  },
265
- {kind: "nullish", inner: const inner} =>
265
+ {kind: "nullish", inner: const inner} =>
266
266
  {
267
267
  anyOf: [convert(inner, path), { type: "null" }],
268
268
  },
269
- {kind: "fallback", inner: _} => {},
270
- {kind: "transformed", inner: const inner} => convert(inner, path),
271
- {kind: "lazy", id: const id, inner: const inner} => recursive(id, inner, path),
272
- {kind: "constrained", inner: const inner, constraint: const constraint} =>
269
+ {kind: "fallback", inner: _} => {},
270
+ {kind: "transformed", inner: const inner} => convert(inner, path),
271
+ {kind: "lazy", id: const id, inner: const inner} => recursive(id, inner, path),
272
+ {kind: "constrained", inner: const inner, constraint: const constraint} =>
273
273
  constrained(inner, constraint, path),
274
274
  };
275
275
  }
package/namespace.js CHANGED
@@ -83,77 +83,77 @@ import { describe, isAsync } from "./schema.js";
83
83
  import { intersect, union, variant } from "./union.js";
84
84
 
85
85
  export const v: {
86
- readonly string: typeof string,
87
- readonly number: typeof number,
88
- readonly bigint: typeof bigint,
89
- readonly boolean: typeof boolean,
90
- readonly unknown: typeof unknown,
91
- readonly never: typeof never,
92
- readonly null: typeof null_,
93
- readonly undefined: typeof undefined_,
94
- readonly literal: typeof literal,
95
- readonly enum: typeof enum_,
96
- readonly date: typeof date,
97
- readonly instance: typeof instance,
98
- readonly custom: typeof custom,
99
- readonly object: typeof object,
100
- readonly strictObject: typeof strictObject,
101
- readonly looseObject: typeof looseObject,
102
- readonly partial: typeof partial,
103
- readonly array: typeof array,
104
- readonly tuple: typeof tuple,
105
- readonly record: typeof record,
106
- readonly map: typeof map,
107
- readonly set: typeof set,
108
- readonly union: typeof union,
109
- readonly variant: typeof variant,
110
- readonly intersect: typeof intersect,
111
- readonly optional: typeof optional,
112
- readonly nullable: typeof nullable,
113
- readonly nullish: typeof nullish,
114
- readonly withDefault: typeof withDefault,
115
- readonly fallback: typeof fallback,
116
- readonly lazy: typeof lazy,
117
- readonly lazyAsync: typeof lazyAsync,
118
- readonly pipe: typeof pipe,
119
- readonly check: typeof check,
120
- readonly checkAsync: typeof checkAsync,
121
- readonly transform: typeof transform,
86
+ readonly string : typeof string,
87
+ readonly number : typeof number,
88
+ readonly bigint : typeof bigint,
89
+ readonly boolean : typeof boolean,
90
+ readonly unknown : typeof unknown,
91
+ readonly never : typeof never,
92
+ readonly null : typeof null_,
93
+ readonly undefined : typeof undefined_,
94
+ readonly literal : typeof literal,
95
+ readonly enum : typeof enum_,
96
+ readonly date : typeof date,
97
+ readonly instance : typeof instance,
98
+ readonly custom : typeof custom,
99
+ readonly object : typeof object,
100
+ readonly strictObject : typeof strictObject,
101
+ readonly looseObject : typeof looseObject,
102
+ readonly partial : typeof partial,
103
+ readonly array : typeof array,
104
+ readonly tuple : typeof tuple,
105
+ readonly record : typeof record,
106
+ readonly map : typeof map,
107
+ readonly set : typeof set,
108
+ readonly union : typeof union,
109
+ readonly variant : typeof variant,
110
+ readonly intersect : typeof intersect,
111
+ readonly optional : typeof optional,
112
+ readonly nullable : typeof nullable,
113
+ readonly nullish : typeof nullish,
114
+ readonly withDefault : typeof withDefault,
115
+ readonly fallback : typeof fallback,
116
+ readonly lazy : typeof lazy,
117
+ readonly lazyAsync : typeof lazyAsync,
118
+ readonly pipe : typeof pipe,
119
+ readonly check : typeof check,
120
+ readonly checkAsync : typeof checkAsync,
121
+ readonly transform : typeof transform,
122
122
  readonly transformAsync: typeof transformAsync,
123
- readonly brand: typeof brand,
124
- readonly refine: typeof refine,
125
- readonly minLength: typeof minLength,
126
- readonly maxLength: typeof maxLength,
127
- readonly length: typeof length,
128
- readonly nonEmpty: typeof nonEmpty,
129
- readonly startsWith: typeof startsWith,
130
- readonly endsWith: typeof endsWith,
131
- readonly includes: typeof includes,
132
- readonly regex: typeof regex,
133
- readonly email: typeof email,
134
- readonly url: typeof url,
135
- readonly uuid: typeof uuid,
136
- readonly isoDate: typeof isoDate,
137
- readonly trim: typeof trim,
138
- readonly toLowerCase: typeof toLowerCase,
139
- readonly toUpperCase: typeof toUpperCase,
140
- readonly min: typeof min,
141
- readonly max: typeof max,
142
- readonly integer: typeof integer,
143
- readonly multipleOf: typeof multipleOf,
144
- readonly minItems: typeof minItems,
145
- readonly maxItems: typeof maxItems,
146
- readonly parse: typeof parse,
147
- readonly safeParse: typeof safeParse,
148
- readonly parseAsync: typeof parseAsync,
123
+ readonly brand : typeof brand,
124
+ readonly refine : typeof refine,
125
+ readonly minLength : typeof minLength,
126
+ readonly maxLength : typeof maxLength,
127
+ readonly length : typeof length,
128
+ readonly nonEmpty : typeof nonEmpty,
129
+ readonly startsWith : typeof startsWith,
130
+ readonly endsWith : typeof endsWith,
131
+ readonly includes : typeof includes,
132
+ readonly regex : typeof regex,
133
+ readonly email : typeof email,
134
+ readonly url : typeof url,
135
+ readonly uuid : typeof uuid,
136
+ readonly isoDate : typeof isoDate,
137
+ readonly trim : typeof trim,
138
+ readonly toLowerCase : typeof toLowerCase,
139
+ readonly toUpperCase : typeof toUpperCase,
140
+ readonly min : typeof min,
141
+ readonly max : typeof max,
142
+ readonly integer : typeof integer,
143
+ readonly multipleOf : typeof multipleOf,
144
+ readonly minItems : typeof minItems,
145
+ readonly maxItems : typeof maxItems,
146
+ readonly parse : typeof parse,
147
+ readonly safeParse : typeof safeParse,
148
+ readonly parseAsync : typeof parseAsync,
149
149
  readonly safeParseAsync: typeof safeParseAsync,
150
- readonly is: typeof is,
151
- readonly parser: typeof parser,
152
- readonly useValidation: typeof useValidation,
153
- readonly describe: typeof describe,
154
- readonly isAsync: typeof isAsync,
155
- readonly flatten: typeof flatten,
156
- readonly toJsonSchema: typeof toJsonSchema,
150
+ readonly is : typeof is,
151
+ readonly parser : typeof parser,
152
+ readonly useValidation : typeof useValidation,
153
+ readonly describe : typeof describe,
154
+ readonly isAsync : typeof isAsync,
155
+ readonly flatten : typeof flatten,
156
+ readonly toJsonSchema : typeof toJsonSchema,
157
157
  } = {
158
158
  string,
159
159
  number,
@@ -161,7 +161,7 @@ export const v: {
161
161
  boolean,
162
162
  unknown,
163
163
  never,
164
- null: null_,
164
+ null : null_,
165
165
  undefined: undefined_,
166
166
  literal,
167
167
  enum: enum_,
package/object.js CHANGED
@@ -76,8 +76,8 @@ function shapeEntries(shape: Shape): $ReadOnlyArray<[string, Schema<mixed, mixed
76
76
  /** Issues for every own key the shape does not name. Empty unless rejecting. */
77
77
  function unknownKeyIssues(
78
78
  source: { readonly [string]: mixed, ... },
79
- named: Set<string>,
80
- path: PathBuffer,
79
+ named : Set<string>,
80
+ path : PathBuffer,
81
81
  ): Array<Issue> {
82
82
  const issues: Array<Issue> = [];
83
83
  for (const key of ownKeys(source)) {
@@ -93,8 +93,8 @@ function unknownKeyIssues(
93
93
  /** Copy every own key the shape does not name into the output, unchecked. */
94
94
  function keepUnknownKeys(
95
95
  source: { readonly [string]: mixed, ... },
96
- named: Set<string>,
97
- out: { [string]: mixed, ... },
96
+ named : Set<string>,
97
+ out : { [string]: mixed, ... },
98
98
  ): void {
99
99
  for (const key of ownKeys(source)) {
100
100
  if (!named.has(key)) {
@@ -111,22 +111,22 @@ function keepUnknownKeys(
111
111
  * exact result, a `Partial` one and an inexact one alike.
112
112
  */
113
113
  function buildObject<TOutput, TInput>(
114
- shape: Shape,
114
+ shape : Shape,
115
115
  unknownKeys: UnknownKeys,
116
116
  ): Schema<TOutput, TInput> {
117
117
  const entries = shapeEntries(shape);
118
118
  const named = new Set(entries.map(([key]) => key));
119
119
  const description = (): Description => ({
120
- kind: "object",
120
+ kind : "object",
121
121
  entries: entries.map(([key, schema]) => [key, describe(schema)]),
122
122
  unknownKeys,
123
123
  });
124
124
 
125
125
  function assemble(
126
126
  source: { readonly [string]: mixed, ... },
127
- out: { [string]: mixed, ... },
128
- found: Array<Issue>,
129
- path: PathBuffer,
127
+ out : { [string]: mixed, ... },
128
+ found : Array<Issue>,
129
+ path : PathBuffer,
130
130
  ): Result<TOutput> {
131
131
  const issues =
132
132
  unknownKeys === "reject" ? found.concat(unknownKeyIssues(source, named, path)) : found;
@@ -153,7 +153,7 @@ function buildObject<TOutput, TInput>(
153
153
  const out: { [string]: mixed, ... } = {};
154
154
  const found: Array<Issue> = [];
155
155
  match (collected) {
156
- {ok: true, values: const values} => {
156
+ {ok: true, values: const values} => {
157
157
  entries.forEach(([key], index) => {
158
158
  put(out, key, values[index]);
159
159
  });
package/optional.js CHANGED
@@ -39,8 +39,8 @@ import { describe, isAsync, makeAsyncSchema, makeSchema, ok, run, runAsync } fro
39
39
  * same three lines.
40
40
  */
41
41
  function wrap<TOutput, TInput>(
42
- inner: Schema<TOutput, mixed>,
43
- shortcut: (value: mixed) => null | Result<TOutput>,
42
+ inner : Schema<TOutput, mixed>,
43
+ shortcut : (value: mixed) => null | Result<TOutput>,
44
44
  description: () => Description,
45
45
  ): Schema<TOutput, TInput> {
46
46
  if (isAsync(inner)) {
@@ -97,7 +97,7 @@ export function nullish<TOutput, TInput>(
97
97
  */
98
98
  export function withDefault<TOutput, TInput>(
99
99
  schema: Schema<TOutput, TInput>,
100
- value: TOutput,
100
+ value : TOutput,
101
101
  ): Schema<TOutput, void | TInput> {
102
102
  return wrap(
103
103
  schema,
@@ -116,7 +116,7 @@ export function withDefault<TOutput, TInput>(
116
116
  */
117
117
  export function fallback<TOutput>(
118
118
  schema: Schema<TOutput, mixed>,
119
- value: TOutput,
119
+ value : TOutput,
120
120
  ): Schema<TOutput, mixed> {
121
121
  const description = (): Description => ({ kind: "fallback", inner: describe(schema) });
122
122
  if (isAsync(schema)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/validator",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "Schemas that parse rather than assert: typed inference, issue paths and JSON Schema export, part of the Unified Toolchain for Flow.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/parse.js CHANGED
@@ -58,7 +58,7 @@ export function parse<TOutput>(schema: Schema<TOutput, mixed>, value: mixed): TO
58
58
  /** [`safeParse`], for a schema with something to wait for. */
59
59
  export function safeParseAsync<TOutput>(
60
60
  schema: Schema<TOutput, mixed>,
61
- value: mixed,
61
+ value : mixed,
62
62
  ): Promise<Result<TOutput>> {
63
63
  return runAsync(schema, value, []);
64
64
  }
@@ -66,7 +66,7 @@ export function safeParseAsync<TOutput>(
66
66
  /** [`parse`], for a schema with something to wait for. */
67
67
  export async function parseAsync<TOutput>(
68
68
  schema: Schema<TOutput, mixed>,
69
- value: mixed,
69
+ value : mixed,
70
70
  ): Promise<TOutput> {
71
71
  const result = await safeParseAsync(schema, value);
72
72
  if (result.ok) {
package/pipe.js CHANGED
@@ -79,60 +79,60 @@ export type Pipe = {
79
79
  <A, AIn, B, C>(schema: Schema<A, AIn>, a: Step<A, B>, b: Step<B, C>): Schema<C, AIn>,
80
80
  <A, AIn, B, C, D>(
81
81
  schema: Schema<A, AIn>,
82
- a: Step<A, B>,
83
- b: Step<B, C>,
84
- c: Step<C, D>,
82
+ a : Step<A, B>,
83
+ b : Step<B, C>,
84
+ c : Step<C, D>,
85
85
  ): Schema<D, AIn>,
86
86
  <A, AIn, B, C, D, E>(
87
87
  schema: Schema<A, AIn>,
88
- a: Step<A, B>,
89
- b: Step<B, C>,
90
- c: Step<C, D>,
91
- d: Step<D, E>,
88
+ a : Step<A, B>,
89
+ b : Step<B, C>,
90
+ c : Step<C, D>,
91
+ d : Step<D, E>,
92
92
  ): Schema<E, AIn>,
93
93
  <A, AIn, B, C, D, E, F>(
94
94
  schema: Schema<A, AIn>,
95
- a: Step<A, B>,
96
- b: Step<B, C>,
97
- c: Step<C, D>,
98
- d: Step<D, E>,
99
- e: Step<E, F>,
95
+ a : Step<A, B>,
96
+ b : Step<B, C>,
97
+ c : Step<C, D>,
98
+ d : Step<D, E>,
99
+ e : Step<E, F>,
100
100
  ): Schema<F, AIn>,
101
101
  <A, AIn, B, C, D, E, F, G>(
102
102
  schema: Schema<A, AIn>,
103
- a: Step<A, B>,
104
- b: Step<B, C>,
105
- c: Step<C, D>,
106
- d: Step<D, E>,
107
- e: Step<E, F>,
108
- f: Step<F, G>,
103
+ a : Step<A, B>,
104
+ b : Step<B, C>,
105
+ c : Step<C, D>,
106
+ d : Step<D, E>,
107
+ e : Step<E, F>,
108
+ f : Step<F, G>,
109
109
  ): Schema<G, AIn>,
110
110
  <A, AIn, B, C, D, E, F, G, H>(
111
111
  schema: Schema<A, AIn>,
112
- a: Step<A, B>,
113
- b: Step<B, C>,
114
- c: Step<C, D>,
115
- d: Step<D, E>,
116
- e: Step<E, F>,
117
- f: Step<F, G>,
118
- g: Step<G, H>,
112
+ a : Step<A, B>,
113
+ b : Step<B, C>,
114
+ c : Step<C, D>,
115
+ d : Step<D, E>,
116
+ e : Step<E, F>,
117
+ f : Step<F, G>,
118
+ g : Step<G, H>,
119
119
  ): Schema<H, AIn>,
120
120
  <A, AIn, B, C, D, E, F, G, H, I>(
121
121
  schema: Schema<A, AIn>,
122
- a: Step<A, B>,
123
- b: Step<B, C>,
124
- c: Step<C, D>,
125
- d: Step<D, E>,
126
- e: Step<E, F>,
127
- f: Step<F, G>,
128
- g: Step<G, H>,
129
- h: Step<H, I>,
122
+ a : Step<A, B>,
123
+ b : Step<B, C>,
124
+ c : Step<C, D>,
125
+ d : Step<D, E>,
126
+ e : Step<E, F>,
127
+ f : Step<F, G>,
128
+ g : Step<G, H>,
129
+ h : Step<H, I>,
130
130
  ): Schema<I, AIn>,
131
131
  ...
132
132
  };
133
133
 
134
134
  function applySteps<TInput>(
135
- schema: Schema<mixed, TInput>,
135
+ schema : Schema<mixed, TInput>,
136
136
  ...steps: $ReadOnlyArray<Step<mixed, mixed>>
137
137
  ): Schema<mixed, TInput> {
138
138
  let piped = schema;
@@ -154,15 +154,15 @@ export const pipe: Pipe = applySteps as Pipe;
154
154
  * what it refined is invisible to every exporter.
155
155
  */
156
156
  export function refine<TOutput, TInput>(
157
- schema: Schema<TOutput, TInput>,
158
- accepts: (value: TOutput) => boolean,
159
- code: string,
160
- message: string,
157
+ schema : Schema<TOutput, TInput>,
158
+ accepts : (value: TOutput) => boolean,
159
+ code : string,
160
+ message : string,
161
161
  constraint: Constraint,
162
- at: Path = [],
162
+ at : Path = [],
163
163
  ): Schema<TOutput, TInput> {
164
164
  const description = (): Description => ({
165
- kind: "constrained",
165
+ kind : "constrained",
166
166
  inner: describe(schema),
167
167
  constraint,
168
168
  });
@@ -200,7 +200,7 @@ export function refine<TOutput, TInput>(
200
200
  export function check<TValue>(
201
201
  accepts: (value: TValue) => boolean,
202
202
  message: string,
203
- at: Path = [],
203
+ at : Path = [],
204
204
  ): Step<TValue, TValue> {
205
205
  return <TInput>(schema: Schema<TValue, TInput>): Schema<TValue, TInput> =>
206
206
  refine(schema, accepts, "check", message, { kind: "opaque", label: message }, at);
@@ -217,7 +217,7 @@ export function check<TValue>(
217
217
  export function checkAsync<TValue>(
218
218
  accepts: (value: TValue) => Promise<boolean>,
219
219
  message: string,
220
- at: Path = [],
220
+ at : Path = [],
221
221
  ): Step<TValue, TValue> {
222
222
  return <TInput>(schema: Schema<TValue, TInput>): Schema<TValue, TInput> =>
223
223
  makeAsyncSchema(
@@ -231,8 +231,8 @@ export function checkAsync<TValue>(
231
231
  : { ok: false, issues: [issueUnder("check", message, path, at)] };
232
232
  },
233
233
  () => ({
234
- kind: "constrained",
235
- inner: describe(schema),
234
+ kind : "constrained",
235
+ inner : describe(schema),
236
236
  constraint: { kind: "opaque", label: message },
237
237
  }),
238
238
  );
@@ -288,8 +288,8 @@ export function transformAsync<TFrom, TTo>(
288
288
  export function brand<TValue>(name: string): Step<TValue, TValue> {
289
289
  return <TInput>(schema: Schema<TValue, TInput>): Schema<TValue, TInput> => {
290
290
  const description = (): Description => ({
291
- kind: "constrained",
292
- inner: describe(schema),
291
+ kind : "constrained",
292
+ inner : describe(schema),
293
293
  constraint: { kind: "brand", name },
294
294
  });
295
295
  if (isAsync(schema)) {
package/plain-object.js CHANGED
@@ -98,8 +98,8 @@ export function put<Value>(out: { [string]: Value, ... }, key: string, value: Va
98
98
  }
99
99
  Object.defineProperty(out, key, {
100
100
  value,
101
- writable: true,
102
- enumerable: true,
101
+ writable : true,
102
+ enumerable : true,
103
103
  configurable: true,
104
104
  });
105
105
  }
package/primitive.js CHANGED
@@ -172,7 +172,7 @@ export function instance<TValue>(ClassValue: Class<TValue>): Schema<TValue, TVal
172
172
  export function custom<TValue>(
173
173
  accepts: (value: mixed) => boolean,
174
174
  message: string,
175
- name: string = "custom",
175
+ name : string = "custom",
176
176
  ): Schema<TValue, TValue> {
177
177
  return makeSchema(
178
178
  (value, path) =>
package/schema.js CHANGED
@@ -94,14 +94,14 @@ export type Description =
94
94
  | {| readonly kind: "map", readonly key: Description, readonly value: Description |}
95
95
  | {| readonly kind: "set", readonly item: Description |}
96
96
  | {|
97
- readonly kind: "object",
98
- readonly entries: $ReadOnlyArray<[string, Description]>,
97
+ readonly kind : "object",
98
+ readonly entries : $ReadOnlyArray<[string, Description]>,
99
99
  readonly unknownKeys: "strip" | "reject" | "keep",
100
100
  |}
101
101
  | {| readonly kind: "union", readonly options: $ReadOnlyArray<Description> |}
102
102
  | {|
103
- readonly kind: "variant",
104
- readonly key: string,
103
+ readonly kind : "variant",
104
+ readonly key : string,
105
105
  readonly branches: $ReadOnlyArray<[string, Description]>,
106
106
  |}
107
107
  | {| readonly kind: "intersect", readonly parts: $ReadOnlyArray<Description> |}
@@ -113,8 +113,8 @@ export type Description =
113
113
  | {| readonly kind: "lazy", readonly id: symbol, readonly inner: () => Description |}
114
114
  | {| readonly kind: "transformed", readonly inner: Description |}
115
115
  | {|
116
- readonly kind: "constrained",
117
- readonly inner: Description,
116
+ readonly kind : "constrained",
117
+ readonly inner : Description,
118
118
  readonly constraint: Constraint,
119
119
  |};
120
120
 
@@ -141,9 +141,9 @@ export type Constraint =
141
141
  | {| readonly kind: "opaque", readonly label: string |};
142
142
 
143
143
  type SchemaKernel<out T> = {|
144
- readonly parse: null | ((mixed, PathBuffer) => Result<T>),
144
+ readonly parse : null | ((mixed, PathBuffer) => Result<T>),
145
145
  readonly parseAsync: null | ((mixed, PathBuffer) => Promise<Result<T>>),
146
- readonly describe: () => Description,
146
+ readonly describe : () => Description,
147
147
  |};
148
148
 
149
149
  /**
@@ -157,8 +157,8 @@ type SchemaKernel<out T> = {|
157
157
  * passed where `Schema<mixed, mixed>` is wanted.
158
158
  */
159
159
  type SchemaCarrier<out TOutput, out TInput> = {|
160
- readonly __kind: "Schema",
161
- readonly __input: () => TInput,
160
+ readonly __kind : "Schema",
161
+ readonly __input : () => TInput,
162
162
  readonly __kernel: SchemaKernel<TOutput>,
163
163
  |};
164
164
 
@@ -201,12 +201,12 @@ const phantomInput = (): empty => {
201
201
 
202
202
  /** Mint a synchronous schema. The only way a `Schema` comes into existence. */
203
203
  export function makeSchema<TOutput, TInput>(
204
- parse: (mixed, PathBuffer) => Result<TOutput>,
204
+ parse : (mixed, PathBuffer) => Result<TOutput>,
205
205
  description: () => Description,
206
206
  ): Schema<TOutput, TInput> {
207
207
  return {
208
- __kind: "Schema",
209
- __input: phantomInput,
208
+ __kind : "Schema",
209
+ __input : phantomInput,
210
210
  __kernel: { parse, parseAsync: null, describe: description },
211
211
  };
212
212
  }
@@ -218,12 +218,12 @@ export function makeSchema<TOutput, TInput>(
218
218
  * reads to decide it is asynchronous too.
219
219
  */
220
220
  export function makeAsyncSchema<TOutput, TInput>(
221
- parseAsync: (mixed, PathBuffer) => Promise<Result<TOutput>>,
221
+ parseAsync : (mixed, PathBuffer) => Promise<Result<TOutput>>,
222
222
  description: () => Description,
223
223
  ): Schema<TOutput, TInput> {
224
224
  return {
225
- __kind: "Schema",
226
- __input: phantomInput,
225
+ __kind : "Schema",
226
+ __input : phantomInput,
227
227
  __kernel: { parse: null, parseAsync, describe: description },
228
228
  };
229
229
  }
@@ -257,9 +257,9 @@ export function run<T>(schema: Schema<T, mixed>, value: mixed, path: PathBuffer)
257
257
  */
258
258
  export function runAt<T>(
259
259
  schema: Schema<T, mixed>,
260
- value: mixed,
261
- path: PathBuffer,
262
- key: string,
260
+ value : mixed,
261
+ path : PathBuffer,
262
+ key : string,
263
263
  ): Result<T> {
264
264
  path.push(key);
265
265
  const result = run(schema, value, path);
@@ -270,8 +270,8 @@ export function runAt<T>(
270
270
  /** Run `schema`, awaiting it if it is asynchronous and calling it if it is not. */
271
271
  export function runAsync<T>(
272
272
  schema: Schema<T, mixed>,
273
- value: mixed,
274
- path: PathBuffer,
273
+ value : mixed,
274
+ path : PathBuffer,
275
275
  ): Promise<Result<T>> {
276
276
  const kernel = schema.__kernel;
277
277
  const parseAsync = kernel.parseAsync;
@@ -290,9 +290,9 @@ export function runAsync<T>(
290
290
  */
291
291
  export function runUnder<T>(
292
292
  schema: Schema<T, mixed>,
293
- value: mixed,
294
- path: PathBuffer,
295
- keys: Path,
293
+ value : mixed,
294
+ path : PathBuffer,
295
+ keys : Path,
296
296
  ): Result<T> {
297
297
  for (const key of keys) {
298
298
  path.push(key);
@@ -307,18 +307,18 @@ export function runUnder<T>(
307
307
  /** Run `schema` deeper, on a path of its own. See the module docs. */
308
308
  export function runAtAsync<T>(
309
309
  schema: Schema<T, mixed>,
310
- value: mixed,
311
- path: PathBuffer,
312
- keys: Path,
310
+ value : mixed,
311
+ path : PathBuffer,
312
+ keys : Path,
313
313
  ): Promise<Result<T>> {
314
314
  return runAsync(schema, value, path.concat(keys));
315
315
  }
316
316
 
317
317
  /** One child of a composite, for [`collectAsync`]. */
318
318
  export type Job = {|
319
- readonly keys: Path,
319
+ readonly keys : Path,
320
320
  readonly schema: Schema<mixed, mixed>,
321
- readonly value: mixed,
321
+ readonly value : mixed,
322
322
  |};
323
323
 
324
324
  /** Every child's outcome, in the order the jobs were given. */
@@ -350,7 +350,7 @@ export async function collectAsync(
350
350
  let issues: null | Array<Issue> = null;
351
351
  for (const result of results) {
352
352
  match (result) {
353
- {ok: true, value: const value} => {
353
+ {ok: true, value: const value} => {
354
354
  values.push(value);
355
355
  }
356
356
  {ok: false, issues: const found} => {
@@ -383,6 +383,6 @@ export function mergeIssues(issues: Array<Issue>, result: Result<mixed>): void {
383
383
  issues.push(entry);
384
384
  }
385
385
  }
386
- _ => {}
386
+ _ => {}
387
387
  }
388
388
  }
package/union.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
 
49
49
  function buildUnion<TOutput, TInput>(options: Options): Schema<TOutput, TInput> {
50
50
  const description = (): Description => ({
51
- kind: "union",
51
+ kind : "union",
52
52
  options: options.map((option) => describe(option)),
53
53
  });
54
54
 
@@ -152,7 +152,7 @@ function buildVariant<TOutput, TInput>(key: string, branches: Shape): Schema<TOu
152
152
  * the control that chooses it.
153
153
  */
154
154
  export function variant<TBranches extends Shape>(
155
- key: string,
155
+ key : string,
156
156
  branches: TBranches,
157
157
  ): Schema<InferOutput<TBranches[keyof TBranches]>, InferInput<TBranches[keyof TBranches]>> {
158
158
  return buildVariant(key, branches);
@@ -176,18 +176,18 @@ export function variant<TBranches extends Shape>(
176
176
  * string and pretend the result satisfies both.
177
177
  */
178
178
  export function intersect<TLeftOut, TLeftIn, TRightOut, TRightIn>(
179
- left: Schema<TLeftOut, TLeftIn>,
179
+ left : Schema<TLeftOut, TLeftIn>,
180
180
  right: Schema<TRightOut, TRightIn>,
181
181
  ): Schema<TLeftOut & TRightOut, TLeftIn & TRightIn> {
182
182
  const description = (): Description => ({
183
- kind: "intersect",
183
+ kind : "intersect",
184
184
  parts: [describe(left), describe(right)],
185
185
  });
186
186
 
187
187
  function combine(
188
- first: Result<TLeftOut>,
188
+ first : Result<TLeftOut>,
189
189
  second: Result<TRightOut>,
190
- path: Array<string>,
190
+ path : Array<string>,
191
191
  ): Result<TLeftOut & TRightOut> {
192
192
  if (!first.ok || !second.ok) {
193
193
  const issues: Array<Issue> = [];