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