2023-02-26 03:28:05 +01:00
|
|
|
import { Schema } from '@/misc/schema';
|
|
|
|
import Ajv from 'ajv';
|
|
|
|
|
|
|
|
export const getValidator = (paramDef: Schema) => {
|
|
|
|
const ajv = new Ajv({
|
|
|
|
useDefaults: true,
|
|
|
|
});
|
2023-07-08 00:08:16 +02:00
|
|
|
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
2023-02-26 03:28:05 +01:00
|
|
|
|
|
|
|
return ajv.compile(paramDef);
|
|
|
|
}
|