fediversity.eu/node_modules/tailwind-bootstrap-grid/lib/validate.js

36 lines
900 B
JavaScript
Raw Permalink Normal View History

2024-03-26 16:28:28 +01:00
const Joi = require('joi');
module.exports =
({ screens }) =>
(input) => {
const makeScreenSubUnit = (schema) =>
Object.keys(screens).reduce(
(obj, screen) => ({ [screen]: schema, ...obj }),
{},
);
const { error } = Joi.object({
gridColumns: Joi.number().integer().min(3).required(),
gridGutterWidth: Joi.string().required(),
gridGutters: Joi.object().required(),
generateContainer: Joi.boolean(),
containerMaxWidths: Joi.object(
makeScreenSubUnit(Joi.string()),
).required(),
rtl: Joi.boolean(),
respectImportant: Joi.boolean(),
})
.required()
.validate(input);
if (error) {
throw new Error(
`tailwind-bootstrap-grid options: \n${JSON.stringify(
input,
null,
2,
)}\nare invalid: ${error} `,
);
}
return input;
};