1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

Ability to add AJV schemas runtime (#2792)

This commit is contained in:
sjaanus 2023-01-06 11:41:39 +02:00 committed by GitHub
parent 2139d8342a
commit 7a1c18bd35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,13 @@ const ajv = new Ajv({
},
});
export const addAjvSchema = (schemaObjects: any[]): any => {
const newSchemas = schemaObjects.filter(
(schema) => !ajv.getSchema(schema.$id),
);
return ajv.addSchema(newSchemas);
};
export const validateSchema = <S = SchemaId>(
schema: S,
data: unknown,