This repository has been archived on 2024-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
fediversity.eu/node_modules/tailwind-bootstrap-grid/lib/validate.js
2024-03-26 16:28:28 +01:00

36 lines
900 B
JavaScript

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;
};