ts-fortress 5.3.0 → 6.0.1

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.
Files changed (47) hide show
  1. package/README.md +9 -6
  2. package/dist/predefined/brand/string/iso-8601.d.mts +4 -4
  3. package/dist/predefined/brand/string/iso-8601.d.mts.map +1 -1
  4. package/dist/predefined/json.d.mts +2 -2
  5. package/dist/record/omit.d.mts +6 -6
  6. package/dist/record/omit.d.mts.map +1 -1
  7. package/dist/record/omit.mjs +2 -1
  8. package/dist/record/omit.mjs.map +1 -1
  9. package/dist/record/partial.d.mts +6 -6
  10. package/dist/record/partial.d.mts.map +1 -1
  11. package/dist/record/partial.mjs +2 -1
  12. package/dist/record/partial.mjs.map +1 -1
  13. package/dist/record/pick.d.mts +6 -6
  14. package/dist/record/pick.d.mts.map +1 -1
  15. package/dist/record/pick.mjs +2 -1
  16. package/dist/record/pick.mjs.map +1 -1
  17. package/dist/record/record.d.mts +22 -8
  18. package/dist/record/record.d.mts.map +1 -1
  19. package/dist/record/record.mjs +49 -18
  20. package/dist/record/record.mjs.map +1 -1
  21. package/dist/record/required.d.mts +6 -6
  22. package/dist/record/required.d.mts.map +1 -1
  23. package/dist/record/required.mjs +2 -1
  24. package/dist/record/required.mjs.map +1 -1
  25. package/dist/type.d.mts +5 -3
  26. package/dist/type.d.mts.map +1 -1
  27. package/dist/utils/create-is-fn.d.mts.map +1 -1
  28. package/dist/utils/create-is-fn.mjs +1 -1
  29. package/dist/utils/create-is-fn.mjs.map +1 -1
  30. package/package.json +11 -10
  31. package/src/record/omit.mts +20 -11
  32. package/src/record/omit.options.test.mts +6 -2
  33. package/src/record/omit.test.mts +42 -3
  34. package/src/record/partial.mts +26 -14
  35. package/src/record/partial.test.mts +105 -5
  36. package/src/record/pick.mts +20 -11
  37. package/src/record/pick.options.test.mts +6 -2
  38. package/src/record/pick.test.mts +64 -9
  39. package/src/record/record-allow-excess-properties.test.mts +65 -28
  40. package/src/record/record-strict-composition-simple.test.mts +45 -12
  41. package/src/record/record-strict-composition.test.mts +12 -3
  42. package/src/record/record.mts +89 -27
  43. package/src/record/record.test.mts +81 -13
  44. package/src/record/required.mts +26 -14
  45. package/src/record/required.test.mts +76 -4
  46. package/src/type.mts +26 -6
  47. package/src/utils/create-is-fn.mts +1 -1
package/README.md CHANGED
@@ -395,14 +395,14 @@ const User = t.record({
395
395
  age: t.number(),
396
396
  });
397
397
 
398
- // Success case - returns the same object reference
398
+ // Success case - validates correctly
399
399
  const validData = { name: 'Alice', age: 30 } as const;
400
400
  const result = User.validate(validData);
401
401
 
402
402
  assert(t.Result.isOk(result));
403
- assert(result.value === validData); // true - same reference!
404
-
403
+ // In strip mode (default), a new object is created even without excess properties
405
404
  assert.deepStrictEqual(result.value, { name: 'Alice', age: 30 });
405
+ assert.notEqual(result.value, validData);
406
406
 
407
407
  // Error case - provides detailed error information
408
408
  const invalidData = { name: 'Bob', age: 'thirty' } as const;
@@ -596,7 +596,8 @@ const StrictUserType = t.record(
596
596
  name: t.string(),
597
597
  },
598
598
  {
599
- allowExcessProperties: false, // Reject any properties not defined in schema
599
+ excessPropertyValidation: 'error', // Reject any properties not defined in schema
600
+ excessPropertyFill: 'strip',
600
601
  },
601
602
  );
602
603
 
@@ -613,7 +614,8 @@ const PermissiveUserType = t.record(
613
614
  name: t.string(),
614
615
  },
615
616
  {
616
- allowExcessProperties: true, // Allow additional properties (default behavior)
617
+ excessPropertyValidation: 'allow', // Allow additional properties (default behavior)
618
+ excessPropertyFill: 'allow',
617
619
  },
618
620
  );
619
621
 
@@ -938,7 +940,8 @@ const StrictType = t.record(
938
940
  age: t.number(),
939
941
  },
940
942
  {
941
- allowExcessProperties: false,
943
+ excessPropertyValidation: 'error',
944
+ excessPropertyFill: 'strip',
942
945
  },
943
946
  );
944
947
 
@@ -16,7 +16,7 @@ declare const ISO8601ValidatorOption: import("../../../type.mjs").RecordType<{
16
16
  assertIs: (a: unknown) => asserts a is boolean;
17
17
  cast: (a: unknown) => boolean;
18
18
  fill: (a: unknown) => boolean;
19
- validate: (a: unknown) => import("ts-data-forge").Result<boolean, readonly Readonly<{
19
+ validate: (a: unknown) => Result<boolean, readonly Readonly<{
20
20
  path: readonly string[];
21
21
  actualValue: unknown;
22
22
  expectedType: string;
@@ -35,7 +35,7 @@ declare const ISO8601ValidatorOption: import("../../../type.mjs").RecordType<{
35
35
  assertIs: (a: unknown) => asserts a is boolean;
36
36
  cast: (a: unknown) => boolean;
37
37
  fill: (a: unknown) => boolean;
38
- validate: (a: unknown) => import("ts-data-forge").Result<boolean, readonly Readonly<{
38
+ validate: (a: unknown) => Result<boolean, readonly Readonly<{
39
39
  path: readonly string[];
40
40
  actualValue: unknown;
41
41
  expectedType: string;
@@ -54,7 +54,7 @@ declare const ISO8601ValidatorOption: import("../../../type.mjs").RecordType<{
54
54
  assertIs: (a: unknown) => asserts a is string;
55
55
  cast: (a: unknown) => string;
56
56
  fill: (a: unknown) => string;
57
- validate: (a: unknown) => import("ts-data-forge").Result<string, readonly Readonly<{
57
+ validate: (a: unknown) => Result<string, readonly Readonly<{
58
58
  path: readonly string[];
59
59
  actualValue: unknown;
60
60
  expectedType: string;
@@ -63,7 +63,7 @@ declare const ISO8601ValidatorOption: import("../../../type.mjs").RecordType<{
63
63
  }>[]>;
64
64
  optional?: true;
65
65
  }>;
66
- }>;
66
+ }, "strip">;
67
67
  type ISO8601ValidatorOption = TypeOf<typeof ISO8601ValidatorOption>;
68
68
  export {};
69
69
  //# sourceMappingURL=iso-8601.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iso-8601.d.mts","sourceRoot":"","sources":["../../../../src/predefined/brand/string/iso-8601.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,sBAAsB,KAAG,IAAI,CAAC,OAAO,CAStE,CAAC;AAEF,QAAA,MAAM,sBAAsB;IAC1B;;OAEG;;;;;;;;;;;;;;;;;IAGH;;OAEG;;;;;;;;;;;;;;;;;IAGH;;OAEG;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,KAAK,sBAAsB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"iso-8601.d.mts","sourceRoot":"","sources":["../../../../src/predefined/brand/string/iso-8601.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,sBAAsB,KAAG,IAAI,CAAC,OAAO,CAStE,CAAC;AAEF,QAAA,MAAM,sBAAsB;IAC1B;;OAEG;;;;;;;;;;;;;;;;;IAGH;;OAEG;;;;;;;;;;;;;;;;;IAGH;;OAEG;;;;;;;;;;;;;;;;;WAEH,CAAC;AAEH,KAAK,sBAAsB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -6,7 +6,7 @@ export declare const JsonPrimitive: Readonly<{
6
6
  assertIs: (a: unknown) => asserts a is string | number | boolean | null;
7
7
  cast: (a: unknown) => string | number | boolean | null;
8
8
  fill: (a: unknown) => string | number | boolean | null;
9
- validate: (a: unknown) => import("ts-data-forge").Result<string | number | boolean | null, readonly Readonly<{
9
+ validate: (a: unknown) => Result<string | number | boolean | null, readonly Readonly<{
10
10
  path: readonly string[];
11
11
  actualValue: unknown;
12
12
  expectedType: string;
@@ -33,7 +33,7 @@ export declare const JsonObject: Readonly<{
33
33
  fill: (a: unknown) => {
34
34
  readonly [x: string]: JsonValue;
35
35
  };
36
- validate: (a: unknown) => import("ts-data-forge").Result<{
36
+ validate: (a: unknown) => Result<{
37
37
  readonly [x: string]: JsonValue;
38
38
  }, readonly Readonly<{
39
39
  path: readonly string[];
@@ -1,9 +1,9 @@
1
- import { type RecordType, type Type } from '../type.mjs';
1
+ import { type ExcessPropertyBehavior, type RecordType, type Type } from '../type.mjs';
2
2
  /** Creates a record type with keys omitted. */
3
- export declare const omit: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToOmit extends readonly (keyof R & string)[]>(recordType: RecordType<R>, keysToOmit: KeysToOmit, options?: PartialReadonly<{
3
+ export declare const omit: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToOmit extends readonly (keyof R & string)[], const ExcessValidation extends ExcessPropertyBehavior = "strip">(recordType: RecordType<R, ExcessValidation>, keysToOmit: KeysToOmit, options?: PartialReadonly<{
4
4
  typeName: string;
5
- /** @default true */
6
- allowExcessProperties: boolean;
7
- }>) => OmittedType<R, KeysToOmit>;
8
- export type OmittedType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToOmit extends readonly (keyof R)[]> = RecordType<Omit<R, ArrayElement<KeysToOmit>>>;
5
+ excessPropertyValidation: ExcessValidation;
6
+ excessPropertyFill: Extract<ExcessPropertyBehavior, "allow" | "strip">;
7
+ }>) => OmittedType<R, KeysToOmit, ExcessValidation>;
8
+ export type OmittedType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToOmit extends readonly (keyof R)[], ExcessValidation extends ExcessPropertyBehavior = 'strip'> = RecordType<Omit<R, ArrayElement<KeysToOmit>>, ExcessValidation>;
9
9
  //# sourceMappingURL=omit.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"omit.d.mts","sourceRoot":"","sources":["../../src/record/omit.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAIzD,+CAA+C;AAC/C,eAAO,MAAM,IAAI,GACf,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACrD,KAAK,CAAC,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAEtD,YAAY,UAAU,CAAC,CAAC,CAAC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O,CAAC,CAAC,EAC/C,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EACvC,gBAAgB,SAAS,sBAAsB,GAAG,OAAO,IACvD,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC"}
@@ -6,7 +6,8 @@ import { record } from './record.mjs';
6
6
  const omit = (recordType, keysToOmit, options) => record(Obj.omit(recordType.shape, keysToOmit), {
7
7
  typeName: options?.typeName ??
8
8
  `Omit<${recordType.typeName}, ${toUnionKeyString(keysToOmit)}>`,
9
- allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
9
+ excessPropertyValidation: options?.excessPropertyValidation ?? recordType.excessPropertyValidation,
10
+ excessPropertyFill: options?.excessPropertyFill ?? recordType.excessPropertyFill,
10
11
  });
11
12
 
12
13
  export { omit };
@@ -1 +1 @@
1
- {"version":3,"file":"omit.mjs","sources":["../../src/record/omit.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
1
+ {"version":3,"file":"omit.mjs","sources":["../../src/record/omit.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;AACO,MAAM,IAAI,GAAG,CAKlB,UAA2C,EAC3C,UAAsB,EACtB,OAIE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,wBAAwB,EACtB,OAAO,EAAE,wBAAwB,IAAI,UAAU,CAAC,wBAAwB;AAC1E,IAAA,kBAAkB,EAChB,OAAO,EAAE,kBAAkB,IAAI,UAAU,CAAC,kBAAkB;AAC/D,CAAA;;;;"}
@@ -1,15 +1,15 @@
1
- import { type RecordType, type Type } from '../type.mjs';
1
+ import { type ExcessPropertyBehavior, type RecordType, type Type } from '../type.mjs';
2
2
  import { type OptionalPropertyType } from './optional.mjs';
3
3
  /**
4
4
  * Creates a Partial type. If keysToBeOptional is set, only those keys are
5
5
  * optional, otherwise, all properties are optional.
6
6
  */
7
- export declare const partial: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToBeOptional extends NonEmptyArray<keyof R & string>>(recordType: RecordType<R>, options?: PartialReadonly<{
7
+ export declare const partial: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToBeOptional extends NonEmptyArray<keyof R & string>, const ExcessValidation extends ExcessPropertyBehavior = "strip">(recordType: RecordType<R, ExcessValidation>, options?: PartialReadonly<{
8
8
  keysToBeOptional: KeysToBeOptional;
9
9
  typeName: string;
10
- /** @default true */
11
- allowExcessProperties: boolean;
12
- }>) => PartialType<R, KeysToBeOptional>;
10
+ excessPropertyValidation: ExcessValidation;
11
+ excessPropertyFill: Extract<ExcessPropertyBehavior, "allow" | "strip">;
12
+ }>) => PartialType<R, KeysToBeOptional, ExcessValidation>;
13
13
  type PartialTypeShape<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeOptional extends NonEmptyArray<keyof R & string> | undefined> = TypeEq<KeysToBeOptional, undefined> extends true ? FullyOptionalType<R> : PartiallyOptionalType<R, ArrayElement<KeysToBeOptional>>;
14
14
  type FullyOptionalType<R extends ReadonlyRecord<string, Type<unknown>>> = {
15
15
  readonly [P in keyof R]: OptionalPropertyType<R[P]>;
@@ -17,6 +17,6 @@ type FullyOptionalType<R extends ReadonlyRecord<string, Type<unknown>>> = {
17
17
  type PartiallyOptionalType<R extends ReadonlyRecord<string, Type<unknown>>, K extends keyof R> = {
18
18
  readonly [P in keyof R]: P extends K ? OptionalPropertyType<R[P]> : R[P];
19
19
  };
20
- export type PartialType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeOptional extends NonEmptyArray<keyof R & string> | undefined> = RecordType<PartialTypeShape<R, KeysToBeOptional>>;
20
+ export type PartialType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeOptional extends NonEmptyArray<keyof R & string> | undefined, ExcessValidation extends ExcessPropertyBehavior = 'strip'> = RecordType<PartialTypeShape<R, KeysToBeOptional>, ExcessValidation>;
21
21
  export {};
22
22
  //# sourceMappingURL=partial.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"partial.d.mts","sourceRoot":"","sources":["../../src/record/partial.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGrE;;;GAGG;AACH,eAAO,MAAM,OAAO,GAClB,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACrD,KAAK,CAAC,gBAAgB,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAE9D,YAAY,UAAU,CAAC,CAAC,CAAC,EACzB,UAAU,eAAe,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,oBAAoB;IACpB,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC,KACD,WAAW,CAAC,CAAC,EAAE,gBAAgB,CA2B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,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,CAAC,SAAS,MAAM,CAAC,IACf;IACF,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC;AAEF,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,gBAAgB,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,SAAS,EACpE,gBAAgB,SAAS,sBAAsB,GAAG,OAAO,IACvD,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAC"}
@@ -18,7 +18,8 @@ const partial = (recordType, options) => {
18
18
  Object.fromEntries(Object.entries(recordType.shape).map(([k, v]) => [k, keysToBeOptional.has(k) ? optional(v) : v]));
19
19
  return record(partialShape, {
20
20
  typeName: typeNameFilled,
21
- allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
21
+ excessPropertyValidation: options?.excessPropertyValidation ?? recordType.excessPropertyValidation,
22
+ excessPropertyFill: options?.excessPropertyFill ?? recordType.excessPropertyFill,
22
23
  });
23
24
  };
24
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"partial.mjs","sources":["../../src/record/partial.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;;;AAGG;MACU,OAAO,GAAG,CAIrB,UAAyB,EACzB,OAME,KACkC;AACpC,IAAA,MAAM,cAAc,GAClB,OAAO,EAAE,QAAQ;AACjB,SAAC,OAAO,EAAE,gBAAgB,KAAK;AAC7B,cAAE,CAAA,QAAA,EAAW,UAAU,CAAC,QAAQ,CAAA,CAAA;AAChC,cAAE,CAAA,iBAAA,EAAoB,UAAU,CAAC,QAAQ,CAAA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ED,IAAA,MAAM,YAAY;;IAEhB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAClC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAU,CACpE,CAIF;IAEH,OAAO,MAAM,CAAC,YAAY,EAAE;AAC1B,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,wBAAwB,EACtB,OAAO,EAAE,wBAAwB,IAAI,UAAU,CAAC,wBAAwB;AAC1E,QAAA,kBAAkB,EAChB,OAAO,EAAE,kBAAkB,IAAI,UAAU,CAAC,kBAAkB;AAC/D,KAAA,CAAC;AACJ;;;;"}
@@ -1,9 +1,9 @@
1
- import { type RecordType, type Type } from '../type.mjs';
1
+ import { type ExcessPropertyBehavior, type RecordType, type Type } from '../type.mjs';
2
2
  /** Creates a record type with keys picked. */
3
- export declare const pick: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToPick extends readonly (keyof R & string)[]>(recordType: RecordType<R>, keysToPick: KeysToPick, options?: PartialReadonly<{
3
+ export declare const pick: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToPick extends readonly (keyof R & string)[], const ExcessValidation extends ExcessPropertyBehavior = "strip">(recordType: RecordType<R, ExcessValidation>, keysToPick: KeysToPick, options?: PartialReadonly<{
4
4
  typeName: string;
5
- /** @default true */
6
- allowExcessProperties: boolean;
7
- }>) => PickedType<R, KeysToPick>;
8
- export type PickedType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToPick extends readonly (keyof R)[]> = RecordType<Pick<R, ArrayElement<KeysToPick>>>;
5
+ excessPropertyValidation: ExcessValidation;
6
+ excessPropertyFill: Extract<ExcessPropertyBehavior, "allow" | "strip">;
7
+ }>) => PickedType<R, KeysToPick, ExcessValidation>;
8
+ export type PickedType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToPick extends readonly (keyof R)[], ExcessValidation extends ExcessPropertyBehavior = 'strip'> = RecordType<Pick<R, ArrayElement<KeysToPick>>, ExcessValidation>;
9
9
  //# sourceMappingURL=pick.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pick.d.mts","sourceRoot":"","sources":["../../src/record/pick.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAIzD,8CAA8C;AAC9C,eAAO,MAAM,IAAI,GACf,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACrD,KAAK,CAAC,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAEtD,YAAY,UAAU,CAAC,CAAC,CAAC,EACzB,YAAY,UAAU,EACtB,UAAU,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IAEjB,oBAAoB;IACpB,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC,KACD,UAAU,CAAC,CAAC,EAAE,UAAU,CAOvB,CAAC;AAEL,MAAM,MAAM,UAAU,CACpB,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,IACrC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"pick.d.mts","sourceRoot":"","sources":["../../src/record/pick.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,IAAI,EACV,MAAM,aAAa,CAAC;AAIrB,8CAA8C;AAC9C,eAAO,MAAM,IAAI,GACf,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACrD,KAAK,CAAC,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EACtD,KAAK,CAAC,gBAAgB,SAAS,sBAAsB,GAAG,OAAO,EAE/D,YAAY,UAAU,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAC3C,YAAY,UAAU,EACtB,UAAU,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB,EAAE,gBAAgB,CAAC;IAC3C,kBAAkB,EAAE,OAAO,CAAC,sBAAsB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;CACxE,CAAC,KACD,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,gBAAgB,CASzC,CAAC;AAEL,MAAM,MAAM,UAAU,CACpB,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,UAAU,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EACvC,gBAAgB,SAAS,sBAAsB,GAAG,OAAO,IACvD,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC"}
@@ -6,7 +6,8 @@ import { record } from './record.mjs';
6
6
  const pick = (recordType, keysToPick, options) => record(Obj.pick(recordType.shape, keysToPick), {
7
7
  typeName: options?.typeName ??
8
8
  `Pick<${recordType.typeName}, ${toUnionKeyString(keysToPick)}>`,
9
- allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
9
+ excessPropertyValidation: options?.excessPropertyValidation ?? recordType.excessPropertyValidation,
10
+ excessPropertyFill: options?.excessPropertyFill ?? recordType.excessPropertyFill,
10
11
  });
11
12
 
12
13
  export { pick };
@@ -1 +1 @@
1
- {"version":3,"file":"pick.mjs","sources":["../../src/record/pick.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
1
+ {"version":3,"file":"pick.mjs","sources":["../../src/record/pick.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;AACO,MAAM,IAAI,GAAG,CAKlB,UAA2C,EAC3C,UAAsB,EACtB,OAIE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,wBAAwB,EACtB,OAAO,EAAE,wBAAwB,IAAI,UAAU,CAAC,wBAAwB;AAC1E,IAAA,kBAAkB,EAChB,OAAO,EAAE,kBAAkB,IAAI,UAAU,CAAC,kBAAkB;AAC/D,CAAA;;;;"}
@@ -1,15 +1,28 @@
1
- import { type RecordType, type Type } from '../type.mjs';
2
- export declare const record: <const R extends ReadonlyRecord<string, Type<unknown>>>(shape: R, options?: PartialReadonly<{
1
+ import { type ExcessPropertyBehavior, type ExcessPropertyFillBehavior, type RecordType, type Type } from '../type.mjs';
2
+ export declare const record: <const R extends ReadonlyRecord<string, Type<unknown>>, const ExcessValidation extends ExcessPropertyBehavior = "strip">(shape: R, options?: PartialReadonly<{
3
3
  typeName: string;
4
- /** @default true */
5
- allowExcessProperties: boolean;
6
- }>) => RecordType<R>;
4
+ /**
5
+ * Behavior when validating objects with excess properties.
6
+ * - 'allow': Accept excess properties
7
+ * - 'strip': Remove excess properties from the result (default)
8
+ * - 'error': Reject objects with excess properties
9
+ * @default 'strip'
10
+ */
11
+ excessPropertyValidation: ExcessValidation;
12
+ /**
13
+ * Behavior when filling objects with excess properties.
14
+ * - 'allow': Keep excess properties in the result
15
+ * - 'strip': Remove excess properties from the result (default)
16
+ * @default 'strip'
17
+ */
18
+ excessPropertyFill: ExcessPropertyFillBehavior;
19
+ }>) => RecordType<R, ExcessValidation>;
7
20
  /**
8
21
  * Creates a strict record type that does not allow excess properties.
9
- * This is an alias for `record(source, { allowExcessProperties: false })`.
22
+ * This is an alias for `record(source, { excessPropertyValidation: 'error' })`.
10
23
  *
11
24
  * @param source - The record schema definition
12
- * @param options - Optional configuration (allowExcessProperties will be overridden to false)
25
+ * @param options - Optional configuration
13
26
  * @returns A Type that validates records without allowing excess properties
14
27
  *
15
28
  * @example
@@ -27,5 +40,6 @@ export declare const record: <const R extends ReadonlyRecord<string, Type<unknow
27
40
  */
28
41
  export declare const strictRecord: <const R extends ReadonlyRecord<string, Type<unknown>>>(source: R, options?: PartialReadonly<{
29
42
  typeName: string;
30
- }>) => RecordType<R>;
43
+ excessPropertyFill: Extract<ExcessPropertyBehavior, "allow" | "strip">;
44
+ }>) => RecordType<R, "error">;
31
45
  //# sourceMappingURL=record.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.mts","sourceRoot":"","sources":["../../src/record/record.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,IAAI,EACV,MAAM,aAAa,CAAC;AAUrB,eAAO,MAAM,MAAM,GAAI,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC1E,OAAO,CAAC,EACR,UAAU,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IAEjB,oBAAoB;I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AAC,KACD,UAAU,CAAC,CAAC,EAAE,OAAO,CAC2C,CAAC"}
@@ -10,10 +10,14 @@ const record = (shape, options) => {
10
10
  `{ ${Object.entries(shape)
11
11
  .map(([k, v]) => `${k}: ${v.typeName}`)
12
12
  .join(', ')} }`;
13
- const allowExcessProperties = options?.allowExcessProperties ?? true;
13
+ const excessPropertyValidation = options?.excessPropertyValidation ?? 'strip';
14
+ const excessPropertyFill = options?.excessPropertyFill ?? 'strip';
14
15
  const defaultValue =
15
16
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
16
17
  Object.fromEntries(Object.entries(shape).map(([key, value]) => tp(key, value.defaultValue)));
18
+ const stripExcessProperties = (obj) =>
19
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
20
+ Object.fromEntries(Object.entries(obj).filter(([key]) => sourceKeys.has(key)));
17
21
  const validate = (a) => {
18
22
  if (!isRecord(a)) {
19
23
  return Result.err([
@@ -51,10 +55,18 @@ const record = (shape, options) => {
51
55
  }
52
56
  }
53
57
  });
54
- // Check for excess properties if allowExcessProperties is false
55
- if (!allowExcessProperties) {
56
- const excessKeys = Object.keys(a).filter((key) => !sourceKeys.has(key));
57
- if (excessKeys.length > 0) {
58
+ switch (excessPropertyValidation) {
59
+ case 'allow':
60
+ return defaultErrors.length > 0
61
+ ? Result.err(defaultErrors)
62
+ : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
63
+ Result.ok(a);
64
+ case 'strip':
65
+ return defaultErrors.length > 0
66
+ ? Result.err(defaultErrors)
67
+ : Result.ok(stripExcessProperties(a));
68
+ case 'error': {
69
+ const excessKeys = Object.keys(a).filter((key) => !sourceKeys.has(key));
58
70
  const excessErrors = excessKeys.map((key) => ({
59
71
  path: [key],
60
72
  actualValue: a[key],
@@ -65,19 +77,36 @@ const record = (shape, options) => {
65
77
  key,
66
78
  },
67
79
  }));
68
- return Result.err([...defaultErrors, ...excessErrors]);
80
+ // Combine all errors
81
+ const allErrors = [...defaultErrors, ...excessErrors];
82
+ return allErrors.length > 0
83
+ ? Result.err(allErrors)
84
+ : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
85
+ Result.ok(a);
69
86
  }
70
87
  }
71
- if (defaultErrors.length > 0) {
72
- return Result.err(defaultErrors);
88
+ };
89
+ const fill = (a) => {
90
+ if (!isRecord(a)) {
91
+ return defaultValue;
92
+ }
93
+ // Handle excess properties based on fill option
94
+ switch (excessPropertyFill) {
95
+ case 'allow': {
96
+ const excessEntries = Object.entries(a).filter(([key]) => !sourceKeys.has(key));
97
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
98
+ return Object.fromEntries([
99
+ ...Object.entries(shape).map(([k, v]) => tp(k, Object.hasOwn(a, k) ? v.fill(a[k]) : v.defaultValue)),
100
+ ...excessEntries,
101
+ ]);
102
+ }
103
+ case 'strip': {
104
+ // For 'strip' or 'error' (treated as 'strip' for fill), return only defined keys
105
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
106
+ return Object.fromEntries(Object.entries(shape).map(([k, v]) => tp(k, Object.hasOwn(a, k) ? v.fill(a[k]) : v.defaultValue)));
107
+ }
73
108
  }
74
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
75
- return Result.ok(a);
76
109
  };
77
- const fill = (a) => isRecord(a)
78
- ? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
79
- Object.fromEntries(Object.entries(shape).map(([k, v]) => tp(k, Object.hasOwn(a, k) ? v.fill(a[k]) : v.defaultValue)))
80
- : defaultValue;
81
110
  return {
82
111
  typeName: typeNameFilled,
83
112
  defaultValue,
@@ -87,15 +116,17 @@ const record = (shape, options) => {
87
116
  assertIs: createAssertFn(validate),
88
117
  cast: createCastFn(validate),
89
118
  shape,
90
- allowExcessProperties,
119
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
120
+ excessPropertyValidation: excessPropertyValidation,
121
+ excessPropertyFill,
91
122
  };
92
123
  };
93
124
  /**
94
125
  * Creates a strict record type that does not allow excess properties.
95
- * This is an alias for `record(source, { allowExcessProperties: false })`.
126
+ * This is an alias for `record(source, { excessPropertyValidation: 'error' })`.
96
127
  *
97
128
  * @param source - The record schema definition
98
- * @param options - Optional configuration (allowExcessProperties will be overridden to false)
129
+ * @param options - Optional configuration
99
130
  * @returns A Type that validates records without allowing excess properties
100
131
  *
101
132
  * @example
@@ -111,7 +142,7 @@ const record = (shape, options) => {
111
142
  * User.is({ name: "John", age: 30, extra: "not allowed" }); // false
112
143
  * ```
113
144
  */
114
- const strictRecord = (source, options) => record(source, { ...options, allowExcessProperties: false });
145
+ const strictRecord = (source, options) => record(source, { ...options, excessPropertyValidation: 'error' });
115
146
 
116
147
  export { record, strictRecord };
117
148
  //# sourceMappingURL=record.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"record.mjs","sources":["../../src/record/record.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;MAea,MAAM,GAAG,CACpB,KAAQ,EACR,OAKE,KACe;AAGjB,IAAA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAE9C,IAAA,MAAM,cAAc,GAClB,OAAO,EAAE,QAAQ;AACjB,QAAA,CAAA,EAAA,EAAK,MAAM,CAAC,OAAO,CAAC,KAAK;AACtB,aAAA,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAA,EAAA,EAAK,CAAC,CAAC,QAAQ,EAAE;AACrC,aAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AAEnB,IAAA,MAAM,qBAAqB,GAAG,OAAO,EAAE,qBAAqB,IAAI,IAAI;AAEpE,IAAA,MAAM,YAAY;;AAEhB,IAAA,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,C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,EAAE,UAAU,CAAC,QAAQ,CAAC;AACxB,QAAA,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;AAClC,QAAA,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;QAC5B,KAAK;;AAEL,QAAA,wBAAwB,EAAE,wBAA4C;QACtE,kBAAkB;KACnB;AACH;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,YAAY,GAAG,CAG1B,MAAS,EACT,OAGE,KAEF,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE;;;;"}
@@ -1,15 +1,15 @@
1
- import { type RecordType, type Type } from '../type.mjs';
1
+ import { type ExcessPropertyBehavior, type RecordType, type Type } from '../type.mjs';
2
2
  import { type RequiredPropertyType } from './optional.mjs';
3
3
  /**
4
4
  * Creates a Required type. If keysToBeRequired is set, only those keys are
5
5
  * made required, otherwise, all properties are made required.
6
6
  */
7
- export declare const required: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToBeRequired extends NonEmptyArray<keyof R & string>>(recordType: RecordType<R>, options?: PartialReadonly<{
7
+ export declare const required: <const R extends ReadonlyRecord<string, Type<unknown>>, const KeysToBeRequired extends NonEmptyArray<keyof R & string>, const ExcessValidation extends ExcessPropertyBehavior = "strip">(recordType: RecordType<R, ExcessValidation>, options?: PartialReadonly<{
8
8
  keysToBeRequired: KeysToBeRequired;
9
9
  typeName: string;
10
- /** @default true */
11
- allowExcessProperties: boolean;
12
- }>) => RequiredType<R, KeysToBeRequired>;
10
+ excessPropertyValidation: ExcessValidation;
11
+ excessPropertyFill: Extract<ExcessPropertyBehavior, "allow" | "strip">;
12
+ }>) => RequiredType<R, KeysToBeRequired, ExcessValidation>;
13
13
  type RequiredTypeShape<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeRequired extends NonEmptyArray<keyof R & string> | undefined> = TypeEq<KeysToBeRequired, undefined> extends true ? FullyRequiredType<R> : PartiallyRequiredType<R, ArrayElement<KeysToBeRequired>>;
14
14
  type FullyRequiredType<R extends ReadonlyRecord<string, Type<unknown>>> = {
15
15
  readonly [P in keyof R]: RequiredPropertyType<R[P]>;
@@ -17,6 +17,6 @@ type FullyRequiredType<R extends ReadonlyRecord<string, Type<unknown>>> = {
17
17
  type PartiallyRequiredType<R extends ReadonlyRecord<string, Type<unknown>>, K extends keyof R> = {
18
18
  readonly [P in keyof R]: P extends K ? RequiredPropertyType<R[P]> : R[P];
19
19
  };
20
- export type RequiredType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeRequired extends NonEmptyArray<keyof R & string> | undefined> = RecordType<RequiredTypeShape<R, KeysToBeRequired>>;
20
+ export type RequiredType<R extends ReadonlyRecord<string, Type<unknown>>, KeysToBeRequired extends NonEmptyArray<keyof R & string> | undefined, ExcessValidation extends ExcessPropertyBehavior = 'strip'> = RecordType<RequiredTypeShape<R, KeysToBeRequired>, ExcessValidation>;
21
21
  export {};
22
22
  //# sourceMappingURL=required.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"required.d.mts","sourceRoot":"","sources":["../../src/record/required.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,QAAQ,GACnB,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACrD,KAAK,CAAC,gBAAgB,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAE9D,YAAY,UAAU,CAAC,CAAC,CAAC,EACzB,UAAU,eAAe,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,oBAAoB;IACpB,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC,KACD,YAAY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,qBAAqB,CACxB,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,CAAC,SAAS,MAAM,CAAC,IACf;IACF,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC;AAEF,MAAM,MAAM,YAAY,CACtB,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAC/C,gBAAgB,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,SAAS,EACpE,gBAAgB,SAAS,sBAAsB,GAAG,OAAO,IACvD,UAAU,CAAC,iBAAiB,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAC"}
@@ -18,7 +18,8 @@ const required = (recordType, options) => {
18
18
  Object.fromEntries(Object.entries(recordType.shape).map(([k, v]) => [k, keysToBeRequired.has(k) ? makeRequired(v) : v]));
19
19
  return record(requiredShape, {
20
20
  typeName: typeNameFilled,
21
- allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
21
+ excessPropertyValidation: options?.excessPropertyValidation ?? recordType.excessPropertyValidation,
22
+ excessPropertyFill: options?.excessPropertyFill ?? recordType.excessPropertyFill,
22
23
  });
23
24
  };
24
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"required.mjs","sources":["../../src/record/required.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUA;;;AAGG;MACU,QAAQ,GAAG,CAItB,UAAyB,EACzB,OAME,KACmC;AACrC,IAAA,MAAM,cAAc,GAClB,OAAO,EAAE,QAAQ;AACjB,SAAC,OAAO,EAAE,gBAAgB,KAAK;AAC7B,cAAE,CAAA,SAAA,EAAY,UAAU,CAAC,QAAQ,CAAA,CAAA;AACjC,cAAE,CAAA,kB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AAO,CAAC,gBAAgB,CAAC,CAAA,CAAA,CAAG,CAAC;AAEjG,IAAA,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CACnD,OAAO,EAAE,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAC3D;AAED,IAAA,MAAM,aAAa;;IAEjB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAClC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAU,CACxE,CAIF;IAEH,OAAO,MAAM,CAAC,aAAa,EAAE;AAC3B,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,wBAAwB,EACtB,OAAO,EAAE,wBAAwB,IAAI,UAAU,CAAC,wBAAwB;AAC1E,QAAA,kBAAkB,EAChB,OAAO,EAAE,kBAAkB,IAAI,UAAU,CAAC,kBAAkB;AAC/D,KAAA,CAAC;AACJ;AAEA;;AAEG;AACH,MAAM,YAAY,GAAG,CACnB,CAAI,KAEJ,kBAAkB,CAAC,CAAC;AAClB;QACG,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC;MACzB,CAAC;;;;"}
package/dist/type.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { type Result } from 'ts-data-forge';
2
1
  import { type ValidationError } from './utils/index.mjs';
3
2
  /**
4
3
  * - `typeName` : Name for this type
@@ -26,9 +25,12 @@ export type TypeOf<A extends Type<unknown>> = A['defaultValue'];
26
25
  export type OptionalType<A> = MergeIntersection<Type<A> & Readonly<{
27
26
  optional: true;
28
27
  }>>;
29
- export type RecordType<R extends ReadonlyRecord<string, Type<unknown>>> = Type<TsFortressInternal.RecordTypeValue<R>> & Readonly<{
28
+ export type ExcessPropertyBehavior = 'allow' | 'strip' | 'error';
29
+ export type ExcessPropertyFillBehavior = Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
30
+ export type RecordType<R extends ReadonlyRecord<string, Type<unknown>>, ExcessPropertyValidation extends ExcessPropertyBehavior = 'strip'> = Type<ExcessPropertyValidation extends 'allow' ? TsFortressInternal.RecordTypeValue<R> | UnknownRecord : TsFortressInternal.RecordTypeValue<R>> & Readonly<{
30
31
  shape: R;
31
- allowExcessProperties: boolean;
32
+ excessPropertyValidation: ExcessPropertyValidation;
33
+ excessPropertyFill: ExcessPropertyFillBehavior;
32
34
  }>;
33
35
  export declare namespace TsFortressInternal {
34
36
  export type RecordTypeValue<R extends ReadonlyRecord<string, Type<unknown>>> = RecordTypeValueImpl<R>;
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.mts","sourceRoot":"","sources":["../src/type.mts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC,CAAC;IAEhE,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB,CA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fn.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,UAAU,GACpB,CAAC,EAAG,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MACjC,GAAG,OAAO,KAAG,CAAC,IAAI,CACO,CAAC"}
1
+ {"version":3,"file":"create-is-fn.d.mts","sourceRoot":"","sources":["../../src/utils/create-is-fn.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,UAAU,GACpB,CAAC,EAAG,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MACjC,GAAG,OAAO,KAAG,CAAC,IAAI,CACS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Result } from 'ts-data-forge';
2
2
 
3
- const createIsFn = (validate) => (a) => Result.isOk(validate(a));
3
+ const createIsFn = (validate) => (a) => !Result.isErr(validate(a));
4
4
 
5
5
  export { createIsFn };
6
6
  //# sourceMappingURL=create-is-fn.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-is-fn.mjs","sources":["../../src/utils/create-is-fn.mts"],"sourcesContent":[null],"names":[],"mappings":";;MAGa,UAAU,GACrB,CAAK,QAA6B,KAClC,CAAC,CAAU,KACT,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"create-is-fn.mjs","sources":["../../src/utils/create-is-fn.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGO,MAAM,UAAU,GACrB,CAAK,QAA6B,KAClC,CAAC,CAAU,KACT,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;;"}