mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 12:47:48 +00:00
30 lines
685 B
JavaScript
30 lines
685 B
JavaScript
module.exports = {
|
|
id: 'local',
|
|
assertions: {
|
|
checkWordsStarts: (value, opts, ctx) => {
|
|
const regexp = new RegExp(`^${opts.words.join('|')}`);
|
|
if (regexp.test(value)) {
|
|
return [];
|
|
}
|
|
return [
|
|
{
|
|
message: `Should start with one of ${opts.words.join(', ')}`,
|
|
location: ctx.baseLocation,
|
|
},
|
|
];
|
|
},
|
|
checkWordsCount: (value, opts, ctx) => {
|
|
const words = value.split(' ');
|
|
if (words.length >= opts.min) {
|
|
return [];
|
|
}
|
|
return [
|
|
{
|
|
message: `Should have at least ${opts.min} words`,
|
|
location: ctx.baseLocation,
|
|
},
|
|
];
|
|
},
|
|
},
|
|
};
|