wildflock/validators.ts

30 lines
662 B
TypeScript
Raw Normal View History

2023-07-29 18:10:00 +00:00
// For more information about this file see https://dove.feathersjs.com/guides/cli/validators.html
2023-08-06 06:21:17 +00:00
import { Ajv, addFormats } from '@feathersjs/schema';
import type { FormatsPluginOptions } from '@feathersjs/schema';
2023-07-29 18:10:00 +00:00
const formats: FormatsPluginOptions = [
2023-08-06 06:21:17 +00:00
'date-time',
'time',
'date',
'email',
'hostname',
'ipv4',
'ipv6',
'uri',
'uri-reference',
'uuid',
'uri-template',
'json-pointer',
'relative-json-pointer',
'regex',
2023-07-29 21:50:42 +00:00
];
2023-07-29 18:10:00 +00:00
2023-07-29 21:50:42 +00:00
export const dataValidator: Ajv = addFormats(new Ajv({}), formats);
2023-07-29 18:10:00 +00:00
export const queryValidator: Ajv = addFormats(
2023-08-06 06:21:17 +00:00
new Ajv({
coerceTypes: true,
}),
formats
2023-07-29 21:50:42 +00:00
);