@tldraw/validate 3.16.0-next.f9f54ec051f3 → 4.0.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/dist-cjs/index.js CHANGED
@@ -41,7 +41,7 @@ var T = __toESM(require("./lib/validation"));
41
41
  var import_validation = require("./lib/validation");
42
42
  (0, import_utils.registerTldrawLibraryVersion)(
43
43
  "@tldraw/validate",
44
- "3.16.0-next.f9f54ec051f3",
44
+ "4.0.0",
45
45
  "cjs"
46
46
  );
47
47
  //# sourceMappingURL=index.js.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./lib/validation.mjs";
10
10
  registerTldrawLibraryVersion(
11
11
  "@tldraw/validate",
12
- "3.16.0-next.f9f54ec051f3",
12
+ "4.0.0",
13
13
  "esm"
14
14
  );
15
15
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/validate",
3
3
  "description": "A runtime validation library by tldraw.",
4
- "version": "3.16.0-next.f9f54ec051f3",
4
+ "version": "4.0.0",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -32,27 +32,19 @@
32
32
  "src"
33
33
  ],
34
34
  "scripts": {
35
- "test-ci": "lazy inherit",
36
- "test": "yarn run -T jest",
37
- "test-coverage": "lazy inherit",
35
+ "test-ci": "yarn run -T vitest run --passWithNoTests",
36
+ "test": "yarn run -T vitest --passWithNoTests",
37
+ "test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
38
38
  "build": "yarn run -T tsx ../../internal/scripts/build-package.ts",
39
39
  "build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",
40
40
  "prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
41
41
  "postpack": "../../internal/scripts/postpack.sh",
42
42
  "pack-tarball": "yarn pack",
43
- "lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
43
+ "lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
44
+ "context": "yarn run -T tsx ../../internal/scripts/context.ts"
44
45
  },
45
46
  "dependencies": {
46
- "@tldraw/utils": "3.16.0-next.f9f54ec051f3"
47
- },
48
- "jest": {
49
- "preset": "../../internal/config/jest/node/jest-preset.js",
50
- "setupFiles": [
51
- "raf/polyfill"
52
- ],
53
- "moduleNameMapper": {
54
- "^~(.*)": "<rootDir>/src/$1"
55
- }
47
+ "@tldraw/utils": "4.0.0"
56
48
  },
57
49
  "devDependencies": {
58
50
  "lazyrepo": "0.0.0-alpha.27"
@@ -17,7 +17,7 @@ describe('validations', () => {
17
17
  it('Rejects unknown object keys', () => {
18
18
  expect(() =>
19
19
  T.object({ moo: T.literal('cow') }).validate({ moo: 'cow', cow: 'moo' })
20
- ).toThrowErrorMatchingInlineSnapshot(`"At cow: Unexpected property"`)
20
+ ).toThrowErrorMatchingInlineSnapshot(`[ValidationError: At cow: Unexpected property]`)
21
21
  })
22
22
  it('Produces nice error messages', () => {
23
23
  expect(() =>
@@ -44,7 +44,9 @@ describe('validations', () => {
44
44
  ],
45
45
  },
46
46
  })
47
- ).toThrowErrorMatchingInlineSnapshot(`"At toad.name: Expected number, got a string"`)
47
+ ).toThrowErrorMatchingInlineSnapshot(
48
+ `[ValidationError: At toad.name: Expected number, got a string]`
49
+ )
48
50
 
49
51
  expect(() =>
50
52
  T.model(
@@ -59,7 +61,9 @@ describe('validations', () => {
59
61
  x: 132,
60
62
  y: NaN,
61
63
  })
62
- ).toThrowErrorMatchingInlineSnapshot(`"At shape.y: Expected a number, got NaN"`)
64
+ ).toThrowErrorMatchingInlineSnapshot(
65
+ `[ValidationError: At shape.y: Expected a number, got NaN]`
66
+ )
63
67
 
64
68
  expect(() =>
65
69
  T.model(
@@ -70,7 +74,7 @@ describe('validations', () => {
70
74
  })
71
75
  ).validate({ id: 'abc13', color: 'rubbish' })
72
76
  ).toThrowErrorMatchingInlineSnapshot(
73
- `"At shape.color: Expected "red" or "green" or "blue", got rubbish"`
77
+ `[ValidationError: At shape.color: Expected "red" or "green" or "blue", got rubbish]`
74
78
  )
75
79
  })
76
80
 
@@ -97,19 +101,19 @@ describe('validations', () => {
97
101
  expect(() =>
98
102
  nested.validate({ animal: { type: 'cow', moo: true, id: 'abc123' } })
99
103
  ).toThrowErrorMatchingInlineSnapshot(
100
- `"At animal.type: Expected one of "cat" or "dog", got "cow""`
104
+ `[ValidationError: At animal.type: Expected one of "cat" or "dog", got "cow"]`
101
105
  )
102
106
 
103
107
  expect(() =>
104
108
  nested.validate({ animal: { type: 'cat', meow: 'yes', id: 'abc123' } })
105
109
  ).toThrowErrorMatchingInlineSnapshot(
106
- `"At animal(type = cat).meow: Expected boolean, got a string"`
110
+ `[ValidationError: At animal(type = cat).meow: Expected boolean, got a string]`
107
111
  )
108
112
 
109
113
  expect(() =>
110
114
  T.model('animal', animalSchema).validate({ type: 'cat', moo: true, id: 'abc123' })
111
115
  ).toThrowErrorMatchingInlineSnapshot(
112
- `"At animal(type = cat).meow: Expected boolean, got undefined"`
116
+ `[ValidationError: At animal(type = cat).meow: Expected boolean, got undefined]`
113
117
  )
114
118
  })
115
119
  })
@@ -130,10 +134,13 @@ describe('T.indexKey', () => {
130
134
  })
131
135
  it('rejects invalid index keys', () => {
132
136
  expect(() => T.indexKey.validate('a')).toThrowErrorMatchingInlineSnapshot(
133
- `"At null: Expected an index key, got "a""`
137
+ `[ValidationError: At null: Expected an index key, got "a"]`
138
+ )
139
+ expect(() => T.indexKey.validate('a00')).toThrowErrorMatchingInlineSnapshot(
140
+ `[ValidationError: At null: Expected an index key, got "a00"]`
134
141
  )
135
142
  expect(() => T.indexKey.validate('')).toThrowErrorMatchingInlineSnapshot(
136
- `"At null: Expected an index key, got """`
143
+ `[ValidationError: At null: Expected an index key, got ""]`
137
144
  )
138
145
  })
139
146
  })