2023-07-27 07:31:52 +02:00
|
|
|
/*
|
2024-02-13 16:59:27 +01:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-26 03:28:05 +01:00
|
|
|
import Ajv from 'ajv';
|
2024-03-07 01:51:57 +01:00
|
|
|
import { Schema } from '@/misc/json-schema.js';
|
2023-02-26 03:28:05 +01:00
|
|
|
|
|
|
|
export const getValidator = (paramDef: Schema) => {
|
2024-03-07 01:51:57 +01:00
|
|
|
const ajv = new Ajv.default({
|
2023-07-27 07:31:52 +02:00
|
|
|
useDefaults: true,
|
|
|
|
});
|
|
|
|
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
2023-02-26 03:28:05 +01:00
|
|
|
|
2023-07-27 07:31:52 +02:00
|
|
|
return ajv.compile(paramDef);
|
|
|
|
};
|