Created
March 15, 2019 10:04
-
-
Save ivarconr/291d5e6f58fc0a02ba58ed6549192cc2 to your computer and use it in GitHub Desktop.
Fix validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/routes/admin-api/feature-schema.js b/lib/routes/admin-api/feature-schema.js | |
index 262ccdc..8039aac 100644 | |
--- a/lib/routes/admin-api/feature-schema.js | |
+++ b/lib/routes/admin-api/feature-schema.js | |
@@ -40,7 +40,11 @@ const featureShema = joi | |
.keys({ | |
name: nameType, | |
enabled: joi.boolean().default(false), | |
- description: joi.string(), | |
+ description: joi | |
+ .string() | |
+ .allow('') | |
+ .allow(null) | |
+ .optional(), | |
strategies: joi | |
.array() | |
.required() | |
@@ -48,10 +52,10 @@ const featureShema = joi | |
.items(strategiesSchema), | |
variants: joi | |
.array() | |
+ .allow(null) | |
.unique((a, b) => a.name === b.name) | |
.optional() | |
- .items(variantsSchema) | |
- .allow(null), | |
+ .items(variantsSchema), | |
}) | |
.options({ allowUnknown: false, stripUnknown: true }); | |
diff --git a/lib/routes/admin-api/strategy-schema.js b/lib/routes/admin-api/strategy-schema.js | |
index 3a61c01..7175e7b 100644 | |
--- a/lib/routes/admin-api/strategy-schema.js | |
+++ b/lib/routes/admin-api/strategy-schema.js | |
@@ -6,7 +6,11 @@ const { nameType } = require('./util'); | |
const strategySchema = joi.object().keys({ | |
name: nameType, | |
editable: joi.boolean().default(true), | |
- description: joi.string(), | |
+ description: joi | |
+ .string() | |
+ .allow(null) | |
+ .allow('') | |
+ .optional(), | |
parameters: joi | |
.array() | |
.required() | |
@@ -14,7 +18,11 @@ const strategySchema = joi.object().keys({ | |
joi.object().keys({ | |
name: joi.string().required(), | |
type: joi.string().required(), | |
- description: joi.string().allow(''), | |
+ description: joi | |
+ .string() | |
+ .allow(null) | |
+ .allow('') | |
+ .optional(), | |
required: joi.boolean(), | |
}) | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment