@logic-pad/core 0.19.0 → 0.19.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 (2) hide show
  1. package/dist/data/puzzle.js +18 -18
  2. package/package.json +1 -1
@@ -1,24 +1,24 @@
1
1
  import { z } from 'zod';
2
2
  import GridData from './grid.js';
3
3
  import { Color, PuzzleType, State } from './primitives.js';
4
- export const MetadataSchema = z
5
- .object({
6
- title: z.string().min(1),
7
- author: z.string().min(1),
8
- description: z.string(),
9
- difficulty: z.number().int().min(0).max(10),
10
- })
11
- .strict();
12
- export const PuzzleSchema = z
13
- .object({
14
- title: z.string().min(1),
15
- author: z.string().min(1),
16
- description: z.string(),
17
- difficulty: z.number().int().min(0).max(10),
18
- grid: z.instanceof(GridData),
19
- solution: z.instanceof(GridData).nullable(),
20
- })
21
- .strict();
4
+ export const MetadataSchema = z.strictObject({
5
+ title: z.string('Title must be a string').min(1, 'Title must not be empty'),
6
+ author: z
7
+ .string('Author must be a string')
8
+ .min(1, 'Author must not be empty'),
9
+ description: z.string('Description must be a string'),
10
+ difficulty: z
11
+ .number('Difficulty must be a number')
12
+ .int('Difficulty must be an integer')
13
+ .min(0, 'Difficulty must be at least 0')
14
+ .max(10, 'Difficulty must be at most 10'),
15
+ }, 'Data must be an object');
16
+ export const PuzzleSchema = MetadataSchema.extend({
17
+ grid: z.instanceof(GridData, { error: 'Grid must be a GridData instance' }),
18
+ solution: z
19
+ .instanceof(GridData, { error: 'Solution must be a GridData instance' })
20
+ .nullable(),
21
+ }).strict();
22
22
  /**
23
23
  * Checks if two puzzles are equal.
24
24
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",