libs/nx/src/executors/extract-plugin-metadata/utils/markdown/markdown-validators.ts
Properties |
|
description | |
Type |
string
|
runtimeCompatible (Optional) | |
Type |
boolean
|
title | |
Type |
string
|
type | |
Type |
TypeInMarkdown.PLUGIN
|
export enum TypeInMarkdown {
'PLUGIN' = 'plugin'
}
export interface MarkdownAttributes {
type: TypeInMarkdown.PLUGIN;
title: string;
description: string;
runtimeCompatible?: boolean;
}
const REQUIRED_MD_ATTRIBUTES: (keyof MarkdownAttributes)[] = ['type', 'title', 'description'];
export const getMissingAttributes = (attrs: MarkdownAttributes) => {
return REQUIRED_MD_ATTRIBUTES.filter((key) => !attrs[key]);
};
export const validateMarkdownAttributes = (attrs: MarkdownAttributes) => {
const errors: { error: string; details?: string[] }[] = [];
const missingAttributes = getMissingAttributes(attrs);
if (missingAttributes.length) {
errors.push({
error: 'missing attributes',
details: missingAttributes
});
}
return errors;
};