forked from feathersjs-ecosystem/validate-joi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
38 lines (32 loc) · 1.27 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Joi from '@hapi/joi';
import { HookContext } from '@feathersjs/feathers';
export interface ValidateJoiOptions {
abortEarly?: boolean,
allowUnknown?: boolean,
cache?: boolean,
convert?: boolean,
debug?: boolean,
externals?: boolean,
noDefaults?: boolean,
nonEnumerables?: boolean,
presence?: Joi.PresenceMode,
skipFunctions?: boolean,
stripUnknown?: boolean,
getContext?: (context: HookContext, next?: (arg0: any, arg1: any) => any) => any,
setContext?: (context: HookContext, next?: (arg0: any, arg1: any) => any) => any,
[option: string]: any
}
export interface RawSchema {
[field: string]: Joi.AnySchema;
}
export interface Translation {
[key: string]: (context?: any) => string | undefined;
}
type FeathersHook = ((context: HookContext) => any);
export interface Validators {
setupValidateProvidedData: (validationsObj: RawSchema, joiOptions?: ValidateJoiOptions) => FeathersHook,
form: (joiSchema: Joi.AnySchema, joiOptions?: ValidateJoiOptions, translations?: Translation, ifTest?: boolean) => FeathersHook,
mongoose: (joiSchema: Joi.AnySchema, joiOptions?: ValidateJoiOptions, translations?: Translation, ifTest?: boolean) => FeathersHook
}
declare const validators: Validators;
export default validators;