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