2023-07-27 07:31:52 +02:00
|
|
|
/*
|
2024-02-12 03:37:45 +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';
|
2023-07-27 07:31:52 +02:00
|
|
|
import { Schema } from '@/misc/schema';
|
2023-02-26 03:28:05 +01:00
|
|
|
|
|
|
|
export const getValidator = (paramDef: Schema) => {
|
2023-07-27 07:31:52 +02:00
|
|
|
const ajv = new Ajv({
|
|
|
|
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);
|
|
|
|
};
|