pema 0.6.0 → 0.7.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.
Files changed (162) hide show
  1. package/lib/private/ArrayType.d.ts +1 -1
  2. package/lib/private/ArrayType.js +11 -4
  3. package/lib/private/BuiltinType.d.ts +1 -1
  4. package/lib/private/BuiltinType.js +6 -2
  5. package/lib/private/ConstructorType.d.ts +1 -1
  6. package/lib/private/ConstructorType.js +3 -1
  7. package/lib/private/DefaultType.d.ts +1 -1
  8. package/lib/private/DefaultType.js +6 -5
  9. package/lib/private/EnumType.d.ts +1 -1
  10. package/lib/private/EnumType.js +5 -2
  11. package/lib/private/FunctionType.d.ts +1 -1
  12. package/lib/private/FunctionType.js +6 -3
  13. package/lib/private/IntType.d.ts +1 -1
  14. package/lib/private/IntType.js +2 -2
  15. package/lib/private/IsType.d.ts +1 -1
  16. package/lib/private/IsType.js +3 -1
  17. package/lib/private/JSONType.d.ts +3 -2
  18. package/lib/private/JSONType.js +3 -1
  19. package/lib/private/LiteralType.d.ts +1 -2
  20. package/lib/private/LiteralType.js +3 -4
  21. package/lib/private/Loose.d.ts +4 -0
  22. package/lib/private/Loose.js +3 -0
  23. package/lib/private/NormalizeSchema.d.ts +3 -3
  24. package/lib/private/NullType.d.ts +1 -1
  25. package/lib/private/NullType.js +5 -2
  26. package/lib/private/NumericType.d.ts +2 -1
  27. package/lib/private/ObjectType.d.ts +1 -1
  28. package/lib/private/ObjectType.js +18 -5
  29. package/lib/private/OmitType.d.ts +1 -1
  30. package/lib/private/OmitType.js +3 -1
  31. package/lib/private/OptionalType.d.ts +1 -1
  32. package/lib/private/OptionalType.js +6 -5
  33. package/lib/private/ParseError.d.ts +1 -1
  34. package/lib/private/ParseError.js +9 -8
  35. package/lib/private/ParseOptions.d.ts +2 -1
  36. package/lib/private/Parsed.d.ts +4 -3
  37. package/lib/private/Parsed.js +2 -3
  38. package/lib/private/PartialType.d.ts +1 -1
  39. package/lib/private/PartialType.js +3 -1
  40. package/lib/private/PrimitiveType.d.ts +1 -1
  41. package/lib/private/PrimitiveType.js +7 -4
  42. package/lib/private/PureType.d.ts +1 -1
  43. package/lib/private/PureType.js +2 -2
  44. package/lib/private/RecordType.d.ts +1 -1
  45. package/lib/private/RecordType.js +3 -1
  46. package/lib/private/Storable.d.ts +1 -0
  47. package/lib/private/Storable.js +4 -0
  48. package/lib/private/StoreType.d.ts +1 -1
  49. package/lib/private/StoreType.js +4 -2
  50. package/lib/private/TupleType.d.ts +1 -1
  51. package/lib/private/TupleType.js +11 -4
  52. package/lib/private/UUIDType.d.ts +1 -1
  53. package/lib/private/UUIDType.js +3 -1
  54. package/lib/private/UUIDV4Type.d.ts +1 -1
  55. package/lib/private/UUIDV4Type.js +3 -1
  56. package/lib/private/UUIDV7Type.d.ts +1 -1
  57. package/lib/private/UUIDV7Type.js +3 -1
  58. package/lib/private/UintType.d.ts +1 -1
  59. package/lib/private/UintType.js +2 -2
  60. package/lib/private/UnionType.d.ts +1 -1
  61. package/lib/private/UnionType.js +6 -4
  62. package/lib/private/VirtualType.js +2 -2
  63. package/lib/private/array.d.ts +6 -4
  64. package/lib/private/array.js +15 -2
  65. package/lib/private/blob.d.ts +6 -2
  66. package/lib/private/blob.js +8 -1
  67. package/lib/private/boolean.d.ts +6 -5
  68. package/lib/private/boolean.js +8 -4
  69. package/lib/private/coerce/date.js +3 -5
  70. package/lib/private/coerce/int.js +1 -1
  71. package/lib/private/constructor.d.ts +6 -5
  72. package/lib/private/constructor.js +16 -1
  73. package/lib/private/date.d.ts +6 -2
  74. package/lib/private/date.js +8 -1
  75. package/lib/private/dict.d.ts +12 -2
  76. package/lib/private/dict.js +10 -2
  77. package/lib/private/enum.d.ts +9 -1
  78. package/lib/private/enum.js +14 -1
  79. package/lib/private/errors.js +5 -6
  80. package/lib/private/f32.d.ts +6 -2
  81. package/lib/private/f32.js +8 -1
  82. package/lib/private/f64.d.ts +6 -2
  83. package/lib/private/f64.js +8 -1
  84. package/lib/private/file.d.ts +6 -2
  85. package/lib/private/file.js +8 -1
  86. package/lib/private/function.d.ts +6 -5
  87. package/lib/private/function.js +8 -1
  88. package/lib/private/i128.d.ts +6 -2
  89. package/lib/private/i128.js +8 -1
  90. package/lib/private/i16.d.ts +6 -2
  91. package/lib/private/i16.js +8 -1
  92. package/lib/private/i32.d.ts +6 -2
  93. package/lib/private/i32.js +8 -1
  94. package/lib/private/i64.d.ts +6 -2
  95. package/lib/private/i64.js +8 -1
  96. package/lib/private/i8.d.ts +6 -2
  97. package/lib/private/i8.js +8 -1
  98. package/lib/private/index.d.ts +33 -15
  99. package/lib/private/index.js +148 -41
  100. package/lib/private/is-parsed.d.ts +3 -0
  101. package/lib/private/is-parsed.js +7 -0
  102. package/lib/private/is.d.ts +6 -2
  103. package/lib/private/is.js +14 -1
  104. package/lib/private/json.d.ts +12 -2
  105. package/lib/private/json.js +14 -1
  106. package/lib/private/literal.d.ts +10 -2
  107. package/lib/private/literal.js +16 -1
  108. package/lib/private/normalize.js +4 -11
  109. package/lib/private/null.d.ts +6 -2
  110. package/lib/private/null.js +8 -1
  111. package/lib/private/object.d.ts +11 -4
  112. package/lib/private/object.js +22 -1
  113. package/lib/private/omit.d.ts +9 -1
  114. package/lib/private/omit.js +14 -1
  115. package/lib/private/partial.d.ts +9 -2
  116. package/lib/private/partial.js +16 -2
  117. package/lib/private/path/next.d.ts +1 -7
  118. package/lib/private/pure.d.ts +9 -1
  119. package/lib/private/pure.js +14 -1
  120. package/lib/private/record.d.ts +6 -5
  121. package/lib/private/record.js +14 -1
  122. package/lib/private/resolve.d.ts +2 -0
  123. package/lib/private/resolve.js +7 -0
  124. package/lib/private/spec/bigint.d.ts +4 -1
  125. package/lib/private/spec/bigint.js +27 -26
  126. package/lib/private/spec/biguint.d.ts +4 -1
  127. package/lib/private/spec/biguint.js +23 -22
  128. package/lib/private/spec/int.d.ts +4 -1
  129. package/lib/private/spec/int.js +24 -23
  130. package/lib/private/spec/uint.d.ts +4 -1
  131. package/lib/private/spec/uint.js +22 -21
  132. package/lib/private/string.d.ts +6 -5
  133. package/lib/private/string.js +8 -4
  134. package/lib/private/symbol.d.ts +6 -2
  135. package/lib/private/symbol.js +8 -1
  136. package/lib/private/test.d.ts +4 -21
  137. package/lib/private/test.js +0 -44
  138. package/lib/private/tuple.d.ts +9 -2
  139. package/lib/private/tuple.js +16 -1
  140. package/lib/private/u128.d.ts +6 -2
  141. package/lib/private/u128.js +8 -1
  142. package/lib/private/u16.d.ts +6 -2
  143. package/lib/private/u16.js +8 -1
  144. package/lib/private/u32.d.ts +6 -5
  145. package/lib/private/u32.js +8 -1
  146. package/lib/private/u64.d.ts +6 -2
  147. package/lib/private/u64.js +8 -1
  148. package/lib/private/u8.d.ts +6 -2
  149. package/lib/private/u8.js +8 -1
  150. package/lib/private/undefined.d.ts +6 -2
  151. package/lib/private/undefined.js +8 -1
  152. package/lib/private/union.d.ts +12 -3
  153. package/lib/private/union.js +14 -1
  154. package/lib/private/unknown.d.ts +6 -5
  155. package/lib/private/unknown.js +8 -1
  156. package/lib/private/url.d.ts +6 -2
  157. package/lib/private/url.js +8 -1
  158. package/lib/private/uuid.d.ts +6 -2
  159. package/lib/private/uuid.js +8 -1
  160. package/package.json +7 -6
  161. package/lib/private/is-parsed-type.d.ts +0 -3
  162. package/lib/private/is-parsed-type.js +0 -6
@@ -1,6 +1,13 @@
1
1
  import BigUintType from "#BigUintType";
2
+ import Loose from "#Loose";
2
3
  import range from "#validator/range";
3
4
  const from = 0n;
4
5
  const to = 2n ** 64n - 1n;
5
- export default new BigUintType("u64", [range(from, to)]);
6
+ const vanilla = new BigUintType("u64", [range(from, to)]);
7
+ const loose = new BigUintType("u64", [range(from, to)]);
8
+ loose[Loose] = true;
9
+ const strict = new BigUintType("u64", [range(from, to)]);
10
+ strict[Loose] = false;
11
+ const u64 = { vanilla, loose, strict };
12
+ export default u64;
6
13
  //# sourceMappingURL=u64.js.map
@@ -1,4 +1,8 @@
1
1
  import UintType from "#UintType";
2
- declare const _default: UintType<"u8">;
3
- export default _default;
2
+ declare const u8: {
3
+ vanilla: UintType<"u8">;
4
+ loose: UintType<"u8">;
5
+ strict: UintType<"u8">;
6
+ };
7
+ export default u8;
4
8
  //# sourceMappingURL=u8.d.ts.map
package/lib/private/u8.js CHANGED
@@ -1,6 +1,13 @@
1
+ import Loose from "#Loose";
1
2
  import UintType from "#UintType";
2
3
  import range from "#validator/range";
3
4
  const from = 0;
4
5
  const to = 2 ** 8 - 1;
5
- export default new UintType("u8", [range(from, to)]);
6
+ const vanilla = new UintType("u8", [range(from, to)]);
7
+ const loose = new UintType("u8", [range(from, to)]);
8
+ loose[Loose] = true;
9
+ const strict = new UintType("u8", [range(from, to)]);
10
+ strict[Loose] = false;
11
+ const u8 = { vanilla, loose, strict };
12
+ export default u8;
6
13
  //# sourceMappingURL=u8.js.map
@@ -1,4 +1,8 @@
1
1
  import UndefinedType from "#UndefinedType";
2
- declare const _default: UndefinedType;
3
- export default _default;
2
+ declare const undefined_: {
3
+ vanilla: UndefinedType;
4
+ loose: UndefinedType;
5
+ strict: UndefinedType;
6
+ };
7
+ export default undefined_;
4
8
  //# sourceMappingURL=undefined.d.ts.map
@@ -1,3 +1,10 @@
1
+ import Loose from "#Loose";
1
2
  import UndefinedType from "#UndefinedType";
2
- export default new UndefinedType();
3
+ const vanilla = new UndefinedType();
4
+ const loose = new UndefinedType();
5
+ loose[Loose] = true;
6
+ const strict = new UndefinedType();
7
+ strict[Loose] = false;
8
+ const undefined_ = { vanilla, loose, strict };
9
+ export default undefined_;
3
10
  //# sourceMappingURL=undefined.js.map
@@ -4,7 +4,16 @@ import UnionType from "#UnionType";
4
4
  type NormalizeArray<T extends Schema[]> = {
5
5
  [K in keyof T]: NormalizeSchema<T[K]>;
6
6
  };
7
- export default function union(): UnionType<[]>;
8
- export default function union<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
9
- export {};
7
+ declare function vanilla(): UnionType<[]>;
8
+ declare function vanilla<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
9
+ declare function loose(): UnionType<[]>;
10
+ declare function loose<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
11
+ declare function strict(): UnionType<[]>;
12
+ declare function strict<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
13
+ declare const union: {
14
+ vanilla: typeof vanilla;
15
+ loose: typeof loose;
16
+ strict: typeof strict;
17
+ };
18
+ export default union;
10
19
  //# sourceMappingURL=union.d.ts.map
@@ -1,6 +1,19 @@
1
+ import Loose from "#Loose";
1
2
  import UnionType from "#UnionType";
2
3
  import normalize from "#normalize";
3
- export default function union(...types) {
4
+ function vanilla(...types) {
4
5
  return new UnionType(types.map(normalize));
5
6
  }
7
+ function loose(...types) {
8
+ const i = new UnionType(types.map(normalize));
9
+ i[Loose] = true;
10
+ return i;
11
+ }
12
+ function strict(...types) {
13
+ const i = new UnionType(types.map(normalize));
14
+ i[Loose] = false;
15
+ return i;
16
+ }
17
+ const union = { vanilla, loose, strict };
18
+ export default union;
6
19
  //# sourceMappingURL=union.js.map
@@ -1,7 +1,8 @@
1
1
  import UnknownType from "#UnknownType";
2
- /**
3
- * Value is an unknown type.
4
- */
5
- declare const _default: UnknownType;
6
- export default _default;
2
+ declare const unknown: {
3
+ vanilla: UnknownType;
4
+ loose: UnknownType;
5
+ strict: UnknownType;
6
+ };
7
+ export default unknown;
7
8
  //# sourceMappingURL=unknown.d.ts.map
@@ -1,6 +1,13 @@
1
+ import Loose from "#Loose";
1
2
  import UnknownType from "#UnknownType";
2
3
  /**
3
4
  * Value is an unknown type.
4
5
  */
5
- export default new UnknownType();
6
+ const vanilla = new UnknownType();
7
+ const loose = new UnknownType();
8
+ loose[Loose] = true;
9
+ const strict = new UnknownType();
10
+ strict[Loose] = false;
11
+ const unknown = { vanilla, loose, strict };
12
+ export default unknown;
6
13
  //# sourceMappingURL=unknown.js.map
@@ -1,4 +1,8 @@
1
1
  import URLType from "#URLType";
2
- declare const _default: URLType;
3
- export default _default;
2
+ declare const url: {
3
+ vanilla: URLType;
4
+ loose: URLType;
5
+ strict: URLType;
6
+ };
7
+ export default url;
4
8
  //# sourceMappingURL=url.d.ts.map
@@ -1,3 +1,10 @@
1
+ import Loose from "#Loose";
1
2
  import URLType from "#URLType";
2
- export default new URLType();
3
+ const vanilla = new URLType();
4
+ const loose = new URLType();
5
+ loose[Loose] = true;
6
+ const strict = new URLType();
7
+ strict[Loose] = false;
8
+ const url = { vanilla, loose, strict };
9
+ export default url;
3
10
  //# sourceMappingURL=url.js.map
@@ -1,4 +1,8 @@
1
1
  import UUIDType from "#UUIDType";
2
- declare const _default: UUIDType;
3
- export default _default;
2
+ declare const uuid: {
3
+ vanilla: UUIDType;
4
+ loose: UUIDType;
5
+ strict: UUIDType;
6
+ };
7
+ export default uuid;
4
8
  //# sourceMappingURL=uuid.d.ts.map
@@ -1,3 +1,10 @@
1
+ import Loose from "#Loose";
1
2
  import UUIDType from "#UUIDType";
2
- export default new UUIDType();
3
+ const vanilla = new UUIDType();
4
+ const loose = new UUIDType();
5
+ loose[Loose] = true;
6
+ const strict = new UUIDType();
7
+ strict[Loose] = false;
8
+ const uuid = { vanilla, loose, strict };
9
+ export default uuid;
3
10
  //# sourceMappingURL=uuid.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pema",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Primate schema validation",
5
5
  "homepage": "https://primate.run/docs/validation",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
@@ -17,13 +17,14 @@
17
17
  "!/**/*.spec.*"
18
18
  ],
19
19
  "dependencies": {
20
- "@rcompat/assert": "^0.8.1",
21
- "@rcompat/cli": "^0.18.1",
22
- "@rcompat/error": "^0.3.1",
23
- "@rcompat/is": "^0.6.1"
20
+ "@rcompat/assert": "^0.13.0",
21
+ "@rcompat/cli": "^0.24.0",
22
+ "@rcompat/error": "^0.8.0",
23
+ "@rcompat/is": "^0.11.0",
24
+ "@rcompat/symbol": "^0.2.0"
24
25
  },
25
26
  "devDependencies": {
26
- "@rcompat/type": "^0.11.1"
27
+ "@rcompat/type": "^0.17.0"
27
28
  },
28
29
  "imports": {
29
30
  "#*": {
@@ -1,3 +0,0 @@
1
- import type Parsed from "#Parsed";
2
- export default function isParsedType(x: unknown): x is Parsed<unknown>;
3
- //# sourceMappingURL=is-parsed-type.d.ts.map
@@ -1,6 +0,0 @@
1
- import ParsedKey from "#ParsedKey";
2
- export default function isParsedType(x) {
3
- return !!x && typeof x === "object" && ParsedKey in x;
4
- }
5
- ;
6
- //# sourceMappingURL=is-parsed-type.js.map