Skip to content

Commit b33f6a3

Browse files
committed
Release 0.13.35
1 parent 46f9fcc commit b33f6a3

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pave",
33
"type": "module",
4-
"version": "0.13.34",
4+
"version": "0.13.35",
55
"author": "Casey Foster <c@sey.me>",
66
"license": "MIT",
77
"repository": {

src/validate-schema.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { Set } = globalThis;
77

88
const { isArray } = Array;
99

10-
/** @param {{ extensions?: { [K: string]: any }; schema: S }} options */
10+
/** @param {{ extensions?: { [K: string]: any }; schema: Schema }} options */
1111
export const validateSchema = ({ extensions, schema }) => {
1212
const positiveNumber = {
1313
resolve: ({ value }) => {
@@ -77,29 +77,11 @@ export const validateSchema = ({ extensions, schema }) => {
7777
oneOf: {
7878
type: typeObject,
7979
validate: ({ path, value }) => {
80-
if (!Object.keys(value).length) {
81-
throw new Error(
82-
`Expected ${`"${path.join('"."')}"`} to define at least one type`
83-
);
84-
}
85-
86-
for (const key in value) {
87-
const type = value[key];
88-
89-
if (typeof type === 'string') {
90-
if (key !== type) {
91-
throw new Error(
92-
`Expected "${key}" at ${`"${path.join('"."')}" to equal "${type}"`}`
93-
);
94-
}
95-
} else if (key in schema) {
96-
throw new Error(
97-
`Expected "${key}" at ${`"${path.join('"."')}" to either equal "${key}" be renamed or to avoid ambiguity`}`
98-
);
99-
}
100-
}
101-
102-
return value;
80+
if (Object.keys(value).length) return value;
81+
82+
throw new Error(
83+
`Expected ${`"${path.join('"."')}"`} to define at least one type`
84+
);
10385
}
10486
},
10587
resolveType: fn

types/validate-schema.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export function validateSchema({ extensions, schema }: {
22
extensions?: {
33
[K: string]: any;
44
};
5-
schema: S;
5+
schema: Schema;
66
}): any;
7+
import type { Schema } from '#types/index.js';

0 commit comments

Comments
 (0)