Team Ai
Apppublic

oex2003/evolution-api

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
template.schema.ts37 linesDownload Raw Back to validate
1import { JSONSchema7 } from 'json-schema';2import { v4 } from 'uuid';3 4const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {5  const properties = {};6  propertyNames.forEach(7    (property) =>8      (properties[property] = {9        minLength: 1,10        description: `The "${property}" cannot be empty`,11      }),12  );13  return {14    if: {15      propertyNames: {16        enum: [...propertyNames],17      },18    },19    then: { properties },20  };21};22 23export const templateSchema: JSONSchema7 = {24  $id: v4(),25  type: 'object',26  properties: {27    name: { type: 'string' },28    category: { type: 'string', enum: ['AUTHENTICATION', 'MARKETING', 'UTILITY'] },29    allowCategoryChange: { type: 'boolean' },30    language: { type: 'string' },31    components: { type: 'array' },32    webhookUrl: { type: 'string' },33  },34  required: ['name', 'category', 'language', 'components'],35  ...isNotEmpty('name', 'category', 'language', 'components'),36};37