mirror of
https://github.com/ComfortablyCoding/strapi-plugin-slugify.git
synced 2025-12-21 00:01:49 -05:00
refactor(config/validator): make validation sync
refactor(config/validator): convert to arrow function for consistency
This commit is contained in:
parent
d44577e9c4
commit
c48e13fb0d
@ -1,11 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { pluginConfigSchema } = require('./schema');
|
const schema = require('./schema');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
async validator(config) {
|
|
||||||
await pluginConfigSchema.validate(config);
|
|
||||||
},
|
|
||||||
default: () => ({
|
default: () => ({
|
||||||
contentTypes: {},
|
contentTypes: {},
|
||||||
slugifyOptions: {},
|
slugifyOptions: {},
|
||||||
@ -13,4 +10,5 @@ module.exports = {
|
|||||||
shouldUpdateSlug: false,
|
shouldUpdateSlug: false,
|
||||||
skipUndefinedReferences: false,
|
skipUndefinedReferences: false,
|
||||||
}),
|
}),
|
||||||
|
validator: (config) => schema.validateSync(config),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
const yup = require('yup');
|
const yup = require('yup');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const pluginConfigSchema = yup.object().shape({
|
const schema = yup.object().shape({
|
||||||
slugifyOptions: yup.object(),
|
slugifyOptions: yup.object(),
|
||||||
contentTypes: yup.lazy((obj) => {
|
contentTypes: yup.lazy((obj) => {
|
||||||
let shape = {};
|
let shape = {};
|
||||||
@ -22,6 +22,4 @@ const pluginConfigSchema = yup.object().shape({
|
|||||||
skipUndefinedReferences: yup.bool(),
|
skipUndefinedReferences: yup.bool(),
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = schema;
|
||||||
pluginConfigSchema,
|
|
||||||
};
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user