Skip to content

Commit

Permalink
Add custom error for node.parent validation (gatsbyjs#2924)
Browse files Browse the repository at this point in the history
* Add custom error for node.parent validation

This error confused several people recently who tried using an empty
string

* Make error an Error object

* Upgrade to Joi v12
  • Loading branch information
KyleAMathews authored Nov 16, 2017
1 parent 940563b commit 8dcc4d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"invariant": "^2.2.2",
"is-relative": "^0.2.1",
"is-relative-url": "^2.0.0",
"joi": "^9.1.1",
"joi": "12.x.x",
"json-loader": "^0.5.2",
"json-stringify-safe": "^5.0.1",
"json5": "^0.5.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby/src/joi-schemas/joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export const nodeSchema = Joi.object()
.required(),
parent: Joi.string()
.allow(null)
.required(),
.required()
.error(() => `"parent" must be the "id" of another node or "null"`),
fields: Joi.object(),
internal: Joi.object().keys({
contentDigest: Joi.string().required(),
Expand Down
28 changes: 18 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6283,6 +6283,12 @@ [email protected]:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isemail/-/isemail-2.2.1.tgz#0353d3d9a62951080c262c2aa0a42b8ea8e9e2a6"

[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/isemail/-/isemail-3.0.0.tgz#c89a46bb7a3361e1759f8028f9082488ecce3dff"
dependencies:
punycode "2.x.x"

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
Expand Down Expand Up @@ -6669,6 +6675,14 @@ jimp@^0.2.24:
tinycolor2 "^1.1.2"
url-regex "^3.0.0"

[email protected]:
version "12.0.0"
resolved "https://registry.yarnpkg.com/joi/-/joi-12.0.0.tgz#46f55e68f4d9628f01bbb695902c8b307ad8d33a"
dependencies:
hoek "4.x.x"
isemail "3.x.x"
topo "2.x.x"

[email protected]:
version "9.0.0-0"
resolved "https://registry.yarnpkg.com/joi/-/joi-9.0.0-0.tgz#a7ca4219602149ae0da7a7c5ca1d63d3c79e096b"
Expand All @@ -6688,16 +6702,6 @@ joi@^6.10.1:
moment "2.x.x"
topo "1.x.x"

joi@^9.1.1:
version "9.2.0"
resolved "https://registry.yarnpkg.com/joi/-/joi-9.2.0.tgz#3385ac790192130cbe230e802ec02c9215bbfeda"
dependencies:
hoek "4.x.x"
isemail "2.x.x"
items "2.x.x"
moment "2.x.x"
topo "2.x.x"

jpeg-js@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.2.0.tgz#53e448ec9d263e683266467e9442d2c5a2ef5482"
Expand Down Expand Up @@ -9842,6 +9846,10 @@ [email protected]:
version "1.3.2"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d"

[email protected]:
version "2.1.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d"

punycode@^1.2.4, punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
Expand Down

0 comments on commit 8dcc4d7

Please sign in to comment.