mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
joi: add LanguageOptions
This commit is contained in:
parent
88ebedb61f
commit
100bdfd79c
19
types/joi/index.d.ts
vendored
19
types/joi/index.d.ts
vendored
@ -6,6 +6,19 @@
|
||||
|
||||
// TODO express type of Schema in a type-parameter (.default, .valid, .example etc)
|
||||
|
||||
export type Types = 'any' | 'alternatives' | 'array' | 'string' | 'number' | 'object' | 'boolean' | 'binary' | 'date' | 'function' | 'lazy';
|
||||
|
||||
export type LanguageRuleOptions = string | false | {
|
||||
[key: string]: LanguageRuleOptions;
|
||||
};
|
||||
|
||||
export type LanguageOptions = {
|
||||
root?: string;
|
||||
key?: string;
|
||||
messages?: { wrapArrays?: boolean; };
|
||||
} & Partial<Record<Types, LanguageRuleOptions>> & {
|
||||
[key: string]: LanguageRuleOptions;
|
||||
};
|
||||
|
||||
export interface ValidationOptions {
|
||||
/**
|
||||
@ -35,7 +48,7 @@ export interface ValidationOptions {
|
||||
/**
|
||||
* overrides individual error messages. Defaults to no override ({}).
|
||||
*/
|
||||
language?: Object;
|
||||
language?: LanguageOptions;
|
||||
/**
|
||||
* sets the default presence requirements. Supported modes: 'optional', 'required', and 'forbidden'. Defaults to 'optional'.
|
||||
*/
|
||||
@ -844,9 +857,7 @@ export interface Extension {
|
||||
name: string;
|
||||
base?: Schema;
|
||||
pre?: (this: AnySchema<AnySchema<Schema>>, params: { [key: string]: any }, value: any, state: State, options: ValidationOptions) => Err | void;
|
||||
language?: {
|
||||
[key: string]: string;
|
||||
},
|
||||
language?: LanguageRuleOptions;
|
||||
describe?: (this: AnySchema<AnySchema<Schema>>, description: any) => any;
|
||||
rules?: Rules[];
|
||||
}
|
||||
|
||||
@ -53,10 +53,25 @@ validOpts = { stripUnknown: bool };
|
||||
validOpts = { stripUnknown: { arrays: bool } };
|
||||
validOpts = { stripUnknown: { objects: bool } };
|
||||
validOpts = { stripUnknown: { arrays: bool, objects: bool } };
|
||||
validOpts = { language: bool };
|
||||
validOpts = { presence: str };
|
||||
validOpts = { context: obj };
|
||||
validOpts = { noDefaults: bool };
|
||||
validOpts = {
|
||||
language: {
|
||||
root: str,
|
||||
key: str,
|
||||
messages: { wrapArrays: bool },
|
||||
string: { base: str },
|
||||
number: { base: str },
|
||||
object: {
|
||||
base: false,
|
||||
children: { childRule: str }
|
||||
},
|
||||
customType: {
|
||||
customRule: str
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user