updated Joi to v4.6.0

This commit is contained in:
Bart van der Schoor
2014-06-13 10:44:14 +02:00
parent e9be9177f6
commit a1fb03f3b6
2 changed files with 366 additions and 94 deletions

View File

@@ -29,27 +29,6 @@ var funcArr: Function[] = [];
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var validOpts: Joi.ValidationOptions = null;
validOpts = {abortEarly: bool};
validOpts = {convert: bool};
validOpts = {allowUnknown: bool};
validOpts = {skipFunctions: bool};
validOpts = {stripUnknown: bool};
validOpts = {language: bool};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var renOpts: Joi.RenameOptions = null;
renOpts = {alias: bool};
renOpts = {multiple: bool};
renOpts = {override: bool};
var validErr: Joi.ValidationError = null;
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var schema: Joi.Schema = null;
var anySchema: Joi.AnySchema<Joi.Schema> = null;
@@ -61,9 +40,66 @@ var binSchema: Joi.BinarySchema = null;
var dateSchema: Joi.DateSchema = null;
var funcSchema: Joi.FunctionSchema = null;
var objSchema: Joi.ObjectSchema = null;
var altSchema: Joi.AlternativesSchema = null;
var schemaArr: Joi.Schema[] = [];
var ref: Joi.Reference = null;
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var validOpts: Joi.ValidationOptions = null;
validOpts = {abortEarly: bool};
validOpts = {convert: bool};
validOpts = {allowUnknown: bool};
validOpts = {skipFunctions: bool};
validOpts = {stripUnknown: bool};
validOpts = {language: bool};
validOpts = {context: obj};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var renOpts: Joi.RenameOptions = null;
renOpts = {alias: bool};
renOpts = {multiple: bool};
renOpts = {override: bool};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var whenOpts: Joi.WhenOptions = null;
whenOpts = {is: schema};
whenOpts = {is: schema, then: schema};
whenOpts = {is: schema, otherwise: schema};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var refOpts: Joi.ReferenceOptions = null;
refOpts = {alias: bool};
refOpts = {multiple: bool};
refOpts = {override: bool};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var validErr: Joi.ValidationError = null;
var validErrItem: Joi.ValidationErrorItem;
validErrItem= {
message: str,
type: str,
path: str
};
validErrItem = {
message: str,
type: str,
path: str,
options: validOpts
};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
schema = anySchema;
@@ -76,6 +112,8 @@ schema = dateSchema;
schema = funcSchema;
schema = objSchema;
schema = ref;
anySchema = anySchema;
anySchema = numSchema;
anySchema = strSchema;
@@ -99,18 +137,22 @@ schemaMap = {
anySchema = Joi.any();
anySchema.validate(x, (err: Joi.ValidationError, value: any) => {
});
module common {
anySchema = anySchema.allow(x);
anySchema = anySchema.allow(x, x);
anySchema = anySchema.allow([x, x, x]);
anySchema = anySchema.valid(x);
anySchema = anySchema.valid(x, x);
anySchema = anySchema.valid([x, x, x]);
anySchema = anySchema.invalid(x);
anySchema = anySchema.invalid(x, x);
anySchema = anySchema.invalid([x, x, x]);
anySchema = anySchema.default(x);
anySchema = anySchema.required();
anySchema = anySchema.optional();
anySchema = anySchema.forbidden();
anySchema = anySchema.description(str);
anySchema = anySchema.notes(str);
@@ -118,8 +160,16 @@ module common {
anySchema = anySchema.tags(str);
anySchema = anySchema.tags(strArr);
anySchema = anySchema.meta(obj);
anySchema = anySchema.example(obj);
anySchema = anySchema.unit(str);
anySchema = anySchema.options(validOpts);
anySchema = anySchema.strict();
anySchema = anySchema.concat(x);
altSchema = anySchema.when(str, whenOpts);
altSchema = anySchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -140,14 +190,23 @@ arrSchema = arrSchema.excludes([numSchema, strSchema]);
// - - - - - - - -
module common {
arrSchema = arrSchema.allow(anyArr);
arrSchema = arrSchema.valid(anyArr);
arrSchema = arrSchema.invalid(anyArr);
arrSchema = arrSchema.default(anyArr);
module common_copy_paste {
// use search & replace from any
anySchema = anySchema.allow(x);
anySchema = anySchema.allow(x, x);
anySchema = anySchema.allow([x, x, x]);
anySchema = anySchema.valid(x);
anySchema = anySchema.valid(x, x);
anySchema = anySchema.valid([x, x, x]);
anySchema = anySchema.invalid(x);
anySchema = anySchema.invalid(x, x);
anySchema = anySchema.invalid([x, x, x]);
anySchema = anySchema.default(x);
arrSchema = arrSchema.required();
arrSchema = arrSchema.optional();
arrSchema = arrSchema.forbidden();
arrSchema = arrSchema.description(str);
arrSchema = arrSchema.notes(str);
@@ -155,8 +214,16 @@ module common {
arrSchema = arrSchema.tags(str);
arrSchema = arrSchema.tags(strArr);
arrSchema = arrSchema.meta(obj);
arrSchema = arrSchema.example(obj);
arrSchema = arrSchema.unit(str);
arrSchema = arrSchema.options(validOpts);
arrSchema = arrSchema.strict();
arrSchema = arrSchema.concat(x);
altSchema = arrSchema.when(str, whenOpts);
altSchema = arrSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -164,14 +231,22 @@ module common {
boolSchema = Joi.bool();
boolSchema = Joi.boolean();
module common {
boolSchema = boolSchema.allow(bool);
boolSchema = boolSchema.valid(bool);
boolSchema = boolSchema.invalid(bool);
boolSchema = boolSchema.default(bool);
module common_copy_paste {
boolSchema = boolSchema.allow(x);
boolSchema = boolSchema.allow(x, x);
boolSchema = boolSchema.allow([x, x, x]);
boolSchema = boolSchema.valid(x);
boolSchema = boolSchema.valid(x, x);
boolSchema = boolSchema.valid([x, x, x]);
boolSchema = boolSchema.invalid(x);
boolSchema = boolSchema.invalid(x, x);
boolSchema = boolSchema.invalid([x, x, x]);
boolSchema = boolSchema.default(x);
boolSchema = boolSchema.required();
boolSchema = boolSchema.optional();
boolSchema = boolSchema.forbidden();
boolSchema = boolSchema.description(str);
boolSchema = boolSchema.notes(str);
@@ -179,8 +254,16 @@ module common {
boolSchema = boolSchema.tags(str);
boolSchema = boolSchema.tags(strArr);
boolSchema = boolSchema.meta(obj);
boolSchema = boolSchema.example(obj);
boolSchema = boolSchema.unit(str);
boolSchema = boolSchema.options(validOpts);
boolSchema = boolSchema.strict();
boolSchema = boolSchema.concat(x);
altSchema = boolSchema.when(str, whenOpts);
altSchema = boolSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -192,13 +275,21 @@ binSchema = binSchema.max(num);
binSchema = binSchema.length(num);
module common {
binSchema = binSchema.allow(bin);
binSchema = binSchema.valid(bin);
binSchema = binSchema.invalid(bin);
binSchema = binSchema.default(bin);
binSchema = binSchema.allow(x);
binSchema = binSchema.allow(x, x);
binSchema = binSchema.allow([x, x, x]);
binSchema = binSchema.valid(x);
binSchema = binSchema.valid(x, x);
binSchema = binSchema.valid([x, x, x]);
binSchema = binSchema.invalid(x);
binSchema = binSchema.invalid(x, x);
binSchema = binSchema.invalid([x, x, x]);
binSchema = binSchema.default(x);
binSchema = binSchema.required();
binSchema = binSchema.optional();
binSchema = binSchema.forbidden();
binSchema = binSchema.description(str);
binSchema = binSchema.notes(str);
@@ -206,8 +297,16 @@ module common {
binSchema = binSchema.tags(str);
binSchema = binSchema.tags(strArr);
binSchema = binSchema.meta(obj);
binSchema = binSchema.example(obj);
binSchema = binSchema.unit(str);
binSchema = binSchema.options(validOpts);
binSchema = binSchema.strict();
binSchema = binSchema.concat(x);
altSchema = binSchema.when(str, whenOpts);
altSchema = binSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -224,23 +323,21 @@ dateSchema = dateSchema.min(num);
dateSchema = dateSchema.max(num);
module common {
dateSchema = dateSchema.allow(date);
dateSchema = dateSchema.valid(date);
dateSchema = dateSchema.invalid(date);
dateSchema = dateSchema.default(date);
dateSchema = dateSchema.allow(num);
dateSchema = dateSchema.valid(num);
dateSchema = dateSchema.invalid(num);
dateSchema = dateSchema.default(num);
dateSchema = dateSchema.allow(str);
dateSchema = dateSchema.valid(str);
dateSchema = dateSchema.invalid(str);
dateSchema = dateSchema.default(str);
dateSchema = dateSchema.allow(x);
dateSchema = dateSchema.allow(x, x);
dateSchema = dateSchema.allow([x, x, x]);
dateSchema = dateSchema.valid(x);
dateSchema = dateSchema.valid(x, x);
dateSchema = dateSchema.valid([x, x, x]);
dateSchema = dateSchema.invalid(x);
dateSchema = dateSchema.invalid(x, x);
dateSchema = dateSchema.invalid([x, x, x]);
dateSchema = dateSchema.default(x);
dateSchema = dateSchema.required();
dateSchema = dateSchema.optional();
dateSchema = dateSchema.forbidden();
dateSchema = dateSchema.description(str);
dateSchema = dateSchema.notes(str);
@@ -248,8 +345,16 @@ module common {
dateSchema = dateSchema.tags(str);
dateSchema = dateSchema.tags(strArr);
dateSchema = dateSchema.meta(obj);
dateSchema = dateSchema.example(obj);
dateSchema = dateSchema.unit(str);
dateSchema = dateSchema.options(validOpts);
dateSchema = dateSchema.strict();
dateSchema = dateSchema.concat(x);
altSchema = dateSchema.when(str, whenOpts);
altSchema = dateSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -265,13 +370,21 @@ numSchema = numSchema.max(num);
numSchema = numSchema.integer();
module common {
numSchema = numSchema.allow(num);
numSchema = numSchema.valid(num);
numSchema = numSchema.invalid(num);
numSchema = numSchema.default(num);
numSchema = numSchema.allow(x);
numSchema = numSchema.allow(x, x);
numSchema = numSchema.allow([x, x, x]);
numSchema = numSchema.valid(x);
numSchema = numSchema.valid(x, x);
numSchema = numSchema.valid([x, x, x]);
numSchema = numSchema.invalid(x);
numSchema = numSchema.invalid(x, x);
numSchema = numSchema.invalid([x, x, x]);
numSchema = numSchema.default(x);
numSchema = numSchema.required();
numSchema = numSchema.optional();
numSchema = numSchema.forbidden();
numSchema = numSchema.description(str);
numSchema = numSchema.notes(str);
@@ -279,8 +392,16 @@ module common {
numSchema = numSchema.tags(str);
numSchema = numSchema.tags(strArr);
numSchema = numSchema.meta(obj);
numSchema = numSchema.example(obj);
numSchema = numSchema.unit(str);
numSchema = numSchema.options(validOpts);
numSchema = numSchema.strict();
numSchema = numSchema.concat(x);
altSchema = numSchema.when(str, whenOpts);
altSchema = numSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -295,29 +416,48 @@ objSchema = objSchema.min(num);
objSchema = objSchema.max(num);
objSchema = objSchema.length(num);
objSchema = objSchema.pattern(exp, schema);
objSchema = objSchema.and(str, str, str);
objSchema = objSchema.and(strArr);
objSchema = objSchema.or(str, str, str);
objSchema = objSchema.or(strArr);
objSchema = objSchema.xor(str, str, str);
objSchema = objSchema.xor(strArr);
objSchema = objSchema.with(str, str);
objSchema = objSchema.with(str, strArr);
objSchema = objSchema.without(str, str);
objSchema = objSchema.without(str, strArr);
objSchema = objSchema.xor(str, str, str);
objSchema = objSchema.xor(strArr);
objSchema = objSchema.or(str, str, str);
objSchema = objSchema.or(strArr);
objSchema = objSchema.rename(str, str);
objSchema = objSchema.rename(str, str, renOpts);
objSchema = objSchema.assert(str, schema, str);
objSchema = objSchema.assert(ref, schema, str);
objSchema = objSchema.unknown();
objSchema = objSchema.unknown(bool);
module common {
objSchema = objSchema.allow(obj);
objSchema = objSchema.valid(obj);
objSchema = objSchema.invalid(obj);
objSchema = objSchema.default(obj);
objSchema = objSchema.allow(x);
objSchema = objSchema.allow(x, x);
objSchema = objSchema.allow([x, x, x]);
objSchema = objSchema.valid(x);
objSchema = objSchema.valid(x, x);
objSchema = objSchema.valid([x, x, x]);
objSchema = objSchema.invalid(x);
objSchema = objSchema.invalid(x, x);
objSchema = objSchema.invalid([x, x, x]);
objSchema = objSchema.default(x);
objSchema = objSchema.required();
objSchema = objSchema.optional();
objSchema = objSchema.forbidden();
objSchema = objSchema.description(str);
objSchema = objSchema.notes(str);
@@ -325,8 +465,16 @@ module common {
objSchema = objSchema.tags(str);
objSchema = objSchema.tags(strArr);
objSchema = objSchema.meta(obj);
objSchema = objSchema.example(obj);
objSchema = objSchema.unit(str);
objSchema = objSchema.options(validOpts);
objSchema = objSchema.strict();
objSchema = objSchema.concat(x);
altSchema = objSchema.when(str, whenOpts);
altSchema = objSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -343,35 +491,43 @@ strSchema = strSchema.token();
strSchema = strSchema.email();
strSchema = strSchema.guid();
strSchema = strSchema.isoDate();
strSchema = strSchema.lowercase();
strSchema = strSchema.uppercase();
strSchema = strSchema.trim();
module common {
strSchema = strSchema.allow(x);
strSchema = strSchema.allow(x, x);
strSchema = strSchema.allow(anyArr);
strSchema = strSchema.allow([x, x, x]);
strSchema = strSchema.valid(x);
strSchema = strSchema.valid(x, x);
strSchema = strSchema.valid(anyArr);
strSchema = strSchema.valid([x, x, x]);
strSchema = strSchema.invalid(x);
strSchema = strSchema.invalid(x, x);
strSchema = strSchema.invalid(anyArr);
strSchema = strSchema.invalid([x, x, x]);
strSchema = strSchema.default(x);
strSchema = strSchema.required();
strSchema = strSchema.optional();
strSchema = strSchema.forbidden();
strSchema = strSchema.description(str);
strSchema = strSchema.notes(str);
strSchema = strSchema.notes(strArr);
strSchema = strSchema.tags(str);
strSchema = strSchema.tags(strArr);
strSchema = strSchema.meta(obj);
strSchema = strSchema.example(obj);
strSchema = strSchema.unit(str);
strSchema = strSchema.options(validOpts);
strSchema = strSchema.strict();
strSchema = strSchema.default(x);
strSchema = strSchema.concat(x);
altSchema = strSchema.when(str, whenOpts);
altSchema = strSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -390,6 +546,13 @@ Joi.validate(value, schema, validOpts, (err, value) => {
str = err.details[0].message;
str = err.details[0].type;
});
Joi.validate(value, schema, (err, value) => {
x = value;
str = err.message;
str = err.details[0].path;
str = err.details[0].message;
str = err.details[0].type;
});
// variant
Joi.validate(num, schema, validOpts, (err, value) => {
num = value;
@@ -401,3 +564,8 @@ Joi.validate(value, {});
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
schema = Joi.compile(obj);
Joi.assert(obj, schema);
ref = Joi.ref(str, refOpts);
ref = Joi.ref(str);

140
joi/joi.d.ts vendored
View File

@@ -1,8 +1,10 @@
// Type definitions for joi v4.0.0
// Type definitions for joi v4.6.0
// Project: https://github.com/spumko/joi
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TODO express type of Schema in a type-parameter (.default, .valid, .example etc)
declare module 'joi' {
export interface ValidationOptions {
@@ -18,6 +20,8 @@ declare module 'joi' {
stripUnknown?: boolean;
// overrides individual error messages. Defaults to no override ({}).
language?: Object
// provides an external data set to be used in references
context?: Object;
}
export interface RenameOptions {
@@ -29,6 +33,20 @@ declare module 'joi' {
override?: boolean;
}
export interface WhenOptions {
// the required condition joi type.
is: Schema;
// the alternative schema type if the condition is true. Required if otherwise is missing.
then?: Schema;
// the alternative schema type if the condition is false. Required if then is missing
otherwise?: Schema;
}
export interface ReferenceOptions {
separator?: string;
contextPrefix?: string;
}
export interface ValidationError {
message: string;
details: ValidationErrorItem[];
@@ -48,12 +66,14 @@ declare module 'joi' {
}
export interface Schema extends AnySchema<Schema> {
}
export interface Reference extends Schema {
}
export interface AnySchema<T extends AnySchema<Schema>> {
validate<U>(value: U, options?: ValidationOptions, callback?: (err: ValidationError, value: U) => void): void;
/**
* Whitelists a value
*/
@@ -82,6 +102,11 @@ declare module 'joi' {
*/
optional(): T;
/**
* Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys.
*/
forbidden(): T;
/**
* Annotates the key
*/
@@ -100,7 +125,22 @@ declare module 'joi' {
tags(notes: string[]): T;
/**
* Overrides the global validate() options for the current key and any sub-key
* Attaches metadata to the key.
*/
meta(meta: Object): T;
/**
* Annotates the key with an example value, must be valid.
*/
example(value: any): T;
/**
* Annotates the key with an unit name.
*/
unit(name: string): T;
/**
* Overrides the global validate() options for the current key and any sub-key.
*/
options(options: ValidationOptions): T;
@@ -110,9 +150,20 @@ declare module 'joi' {
strict(): T;
/**
* Sets a default value if the original value is undefined
* Sets a default value if the original value is undefined.
*/
default(value: any): T;
/**
* Returns a new type that is the result of adding the rules of one type to another.
*/
concat(schema: T): T;
/**
* Converts the type into an alternatives type where the conditions are merged into the type definition where:
*/
when(ref: string, options: WhenOptions): AlternativesSchema;
when(ref: Reference, options: WhenOptions): AlternativesSchema;
}
export interface BooleanSchema extends AnySchema<BooleanSchema> {
@@ -187,6 +238,20 @@ declare module 'joi' {
*/
isoDate(): StringSchema;
/**
* Requires the string value to be all lowercase. If the validation convert option is on (enabled by default), the string will be forced to lowercase.
*/
lowercase(): StringSchema;
/**
* Requires the string value to be all uppercase. If the validation convert option is on (enabled by default), the string will be forced to uppercase.
*/
uppercase(): StringSchema;
/**
* Requires the string value to contain no whitespace before or after. If the validation convert option is on (enabled by default), the string will be trimmed.
*/
trim(): StringSchema;
}
export interface ArraySchema extends AnySchema<ArraySchema> {
@@ -240,6 +305,29 @@ declare module 'joi' {
*/
length(limit: number): ObjectSchema;
/**
* Specify validation rules for unknown keys matching a pattern.
*/
pattern(regex: RegExp, schema: Schema): ObjectSchema;
/**
* Defines an all-or-nothing relationship between keys where if one of the peers is present, all of them are required as well.
*/
and(peer1: string, peer2: string, ...peers: string[]): ObjectSchema;
and(peers: string[]): ObjectSchema;
/**
* Defines a relationship between keys where one of the peers is required (and more than one is allowed).
*/
or(peer1: string, peer2: string, ...peers: string[]): ObjectSchema;
or(peers: string[]): ObjectSchema;
/**
* Defines an exclusive relationship between a set of keys. one of them is required but not at the same time where:
*/
xor(peer1: string, peer2: string, ...peers: string[]): ObjectSchema;
xor(peers: string[]): ObjectSchema;
/**
* Requires the presence of other keys whenever the specified key is present.
*/
@@ -252,22 +340,21 @@ declare module 'joi' {
without(key: string, peers: string): ObjectSchema;
without(key: string, peers: string[]): ObjectSchema;
/**
* Defines an exclusive relationship between a set of keys. one of them is required but not at the same time where:
*/
xor(peer1: string, peer2: string, ...peers: string[]): ObjectSchema;
xor(peers: string[]): ObjectSchema;
/**
* Defines a relationship between keys where one of the peers is required (and more than one is allowed).
*/
or(peer1: string, peer2: string, ...peers: string[]): ObjectSchema;
or(peers: string[]): ObjectSchema;
/**
* Renames a key to another name (deletes the renamed key).
*/
rename(from: string, to: string, options?: RenameOptions): ObjectSchema;
/**
* Verifies an assertion where.
*/
assert(ref: string, schema: Schema, message: string): ObjectSchema;
assert(ref: Reference, schema: Schema, message: string): ObjectSchema;
/**
* Overrides the handling of unknown keys for the scope of the current object only (does not apply to children).
*/
unknown(allow?:boolean): ObjectSchema;
}
export interface BinarySchema extends AnySchema<BinarySchema> {
@@ -308,6 +395,12 @@ declare module 'joi' {
}
export interface AlternativesSchema extends AnySchema<FunctionSchema> {
try(schemas: Schema[]): AlternativesSchema;
when(ref: string, options: WhenOptions): AlternativesSchema;
when(ref: Reference, options: WhenOptions): AlternativesSchema;
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
/**
@@ -368,10 +461,21 @@ declare module 'joi' {
*/
export function validate<T>(value: T, schema: Schema, options?: ValidationOptions, callback?: (err: ValidationError, value: T) => void): void;
export function validate<T>(value: T, schema: Object, options?: ValidationOptions, callback?: (err: ValidationError, value: T) => void): void;
export function validate<T>(value: T, schema: Schema, callback: (err: ValidationError, value: T) => void): void;
export function validate<T>(value: T, schema: Object, callback: (err: ValidationError, value: T) => void): void;
/**
* Converts literal schema definition to joi schema object (or returns the same back if already a joi schema object).
*/
export function compile(schema: Object): Schema;
/**
* Validates a value against a schema and throws if validation fails.
*/
export function assert(value: any, schema: Schema): void;
/**
* Generates a reference to the value of the named key.
*/
export function ref(key:string, options?: ReferenceOptions): Reference;
}