mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-16 21:06:35 +08:00
fix: better meta validation errors (#57180)
Some checks failed
i18n - Build Validation / Validate i18n Builds (20.x) (push) Has been cancelled
CI - Node.js / Lint (20.x) (push) Has been cancelled
CI - Node.js / Build (20.x) (push) Has been cancelled
CI - Node.js / Test (20.x) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20.x) (push) Has been cancelled
i18n - Download Client UI / Client (push) Has been cancelled
Some checks failed
i18n - Build Validation / Validate i18n Builds (20.x) (push) Has been cancelled
CI - Node.js / Lint (20.x) (push) Has been cancelled
CI - Node.js / Build (20.x) (push) Has been cancelled
CI - Node.js / Test (20.x) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20.x) (push) Has been cancelled
i18n - Download Client UI / Client (push) Has been cancelled
This commit is contained in:
parent
63db50abba
commit
653629f8db
@ -1,5 +1,7 @@
|
||||
const Joi = require('joi');
|
||||
|
||||
const { SuperBlocks } = require('../../shared/config/curriculum');
|
||||
|
||||
const slugRE = new RegExp('^[a-z0-9-]+$');
|
||||
const slugWithSlashRE = new RegExp('^[a-z0-9-/]+$');
|
||||
|
||||
@ -25,7 +27,10 @@ const schema = Joi.object()
|
||||
),
|
||||
isUpcomingChange: Joi.boolean().required(),
|
||||
dashedName: Joi.string().regex(slugRE).required(),
|
||||
superBlock: Joi.string().regex(slugWithSlashRE).required(),
|
||||
superBlock: Joi.string()
|
||||
.regex(slugWithSlashRE)
|
||||
.valid(...Object.values(SuperBlocks))
|
||||
.required(),
|
||||
order: Joi.number().when('superBlock', {
|
||||
is: 'full-stack-developer',
|
||||
then: Joi.forbidden(),
|
||||
@ -73,5 +78,5 @@ const schema = Joi.object()
|
||||
.unknown(false);
|
||||
|
||||
exports.metaSchemaValidator = meta => {
|
||||
return schema.validate(meta);
|
||||
return schema.validate(meta, { abortEarly: false });
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user