mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-10 18:39:38 -06:00
33 lines
715 B
TypeScript
33 lines
715 B
TypeScript
import { JSONSchema7 } from 'json-schema';
|
|
import { v4 } from 'uuid';
|
|
|
|
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
|
const properties: Record<string, unknown> = {};
|
|
propertyNames.forEach(
|
|
(property) =>
|
|
(properties[property] = {
|
|
minLength: 1,
|
|
description: `The "${property}" cannot be empty`,
|
|
}),
|
|
);
|
|
return {
|
|
if: {
|
|
propertyNames: {
|
|
enum: [...propertyNames],
|
|
},
|
|
},
|
|
then: { properties },
|
|
} as JSONSchema7;
|
|
};
|
|
|
|
export const templateDeleteSchema: JSONSchema7 = {
|
|
$id: v4(),
|
|
type: 'object',
|
|
properties: {
|
|
name: { type: 'string' },
|
|
hsmId: { type: 'string' },
|
|
},
|
|
required: ['name'],
|
|
...isNotEmpty('name'),
|
|
};
|