File

libs/nx/src/executors/extract-plugin-metadata/compat/utils/markdown/markdown-validators.ts

Index

Properties

Properties

description
Type string
title
Type string
type
Type TypeInMarkdown.PLUGIN
export enum TypeInMarkdown {
  'PLUGIN' = 'plugin'
}

export interface MarkdownAttributes {
  type: TypeInMarkdown.PLUGIN;
  title: string;
  description: string;
}

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

results matching ""

    No results matching ""