huridocs/uwazi

View on GitHub
app/api/entities/validation/validateEntitySchema.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import Ajv from 'ajv';
import { entitySchema } from 'shared/types/entitySchema';
import { wrapValidator } from 'shared/tsUtils';

const ajv = new Ajv({ allErrors: true });
ajv.addVocabulary(['tsType']);

export const validateEntitySchema = async (entity: any) =>
  wrapValidator(ajv.compile(entitySchema))(entity);