2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-14 00:50:11 +09:00
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-26 11:28:05 +09:00
|
|
|
import Ajv from 'ajv';
|
2023-07-27 14:31:52 +09:00
|
|
|
import { Schema } from '@/misc/schema';
|
2023-02-26 11:28:05 +09:00
|
|
|
|
|
|
|
export const getValidator = (paramDef: Schema) => {
|
2023-07-27 14:31:52 +09:00
|
|
|
const ajv = new Ajv({
|
|
|
|
useDefaults: true,
|
|
|
|
});
|
|
|
|
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
2023-02-26 11:28:05 +09:00
|
|
|
|
2023-07-27 14:31:52 +09:00
|
|
|
return ajv.compile(paramDef);
|
|
|
|
};
|