Skip to content

Commit

Permalink
Add expectedObject check, 0.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
caseywebdev committed Jun 15, 2023
1 parent a33fd8e commit 68f164e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pave",
"type": "module",
"version": "0.13.1",
"version": "0.13.2",
"author": "Casey Foster <c@sey.me>",
"license": "MIT",
"main": "src/index.js",
Expand All @@ -14,5 +14,9 @@
"devDependencies": {
"watchy": "0.10",
"kiss-test": "0.2"
}
},
"files": [
"/src/*.js",
"!/src/*.test.js"
]
}
5 changes: 5 additions & 0 deletions src/throw-pave-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const messages = {
expectedNonNull: ({ path }) =>
`A non-null value is required at ${formatPath(path)}`,

expectedObject: ({ path, value }) =>
`The value ${JSON.stringify(value)} at ${formatPath(
path
)} must be an object`,

expectedOneOfType: ({ path, type: { oneOf }, value }) =>
`The value ${JSON.stringify(value)} at ${formatPath(
path
Expand Down
2 changes: 2 additions & 0 deletions src/validate-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ const validateValue = ({
}

if (type.object) {
if (!isObject(value)) fail('expectedObject');

let check = {};
for (const key in type.object) check[key] = undefined;
check = { ...check, ...value };
Expand Down

0 comments on commit 68f164e

Please sign in to comment.