yedra 0.10.2 → 0.10.3

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/lib.d.ts CHANGED
@@ -23,3 +23,4 @@ export { string } from './validation/string.js';
23
23
  export { _undefined as undefined } from './validation/undefined.js';
24
24
  export { union } from './validation/union.js';
25
25
  export { unknown } from './validation/unknown.js';
26
+ export { uuid } from './validation/uuid.js';
package/dist/lib.js CHANGED
@@ -28,3 +28,4 @@ export { string } from './validation/string.js';
28
28
  export { _undefined as undefined } from './validation/undefined.js';
29
29
  export { union } from './validation/union.js';
30
30
  export { unknown } from './validation/unknown.js';
31
+ export { uuid } from './validation/uuid.js';
@@ -0,0 +1,11 @@
1
+ import { ModifiableSchema } from './modifiable.js';
2
+ declare class UuidSchema extends ModifiableSchema<string> {
3
+ parse(obj: unknown): string;
4
+ documentation(): object;
5
+ }
6
+ /**
7
+ * A schema matching a universally unique identifier UUID
8
+ * of version 4.
9
+ */
10
+ export declare const uuid: () => UuidSchema;
11
+ export {};
@@ -0,0 +1,23 @@
1
+ import { validate, version } from 'uuid';
2
+ import { Issue, ValidationError } from './error.js';
3
+ import { ModifiableSchema } from './modifiable.js';
4
+ class UuidSchema extends ModifiableSchema {
5
+ parse(obj) {
6
+ if (typeof obj !== 'string' || !validate(obj) || version(obj) !== 4) {
7
+ throw new ValidationError([
8
+ new Issue('invalidType', [], 'uuid', typeof obj),
9
+ ]);
10
+ }
11
+ return obj;
12
+ }
13
+ documentation() {
14
+ return {
15
+ type: 'string',
16
+ };
17
+ }
18
+ }
19
+ /**
20
+ * A schema matching a universally unique identifier UUID
21
+ * of version 4.
22
+ */
23
+ export const uuid = () => new UuidSchema();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yedra",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "repository": "github:0codekit/yedra",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {
@@ -21,6 +21,8 @@
21
21
  "types": "dist/index.d.ts",
22
22
  "type": "module",
23
23
  "dependencies": {
24
- "glob": "^11.0.0"
24
+ "@types/uuid": "^10.0.0",
25
+ "glob": "^11.0.0",
26
+ "uuid": "^10.0.0"
25
27
  }
26
28
  }