[joi] Update joi definitions to match current version (13.0.1 -> 13.3.0)

* Add optional options package for string.hex
* Add number.port option
* Add object.append method
* Add Joi.reach overloads with path argument having an array of strings
* Update documentation strings for reach, keys
This commit is contained in:
Peter Thorson
2018-06-03 15:43:51 -05:00
parent e4a45e562b
commit 24b31d8563
2 changed files with 37 additions and 4 deletions
+25 -4
View File
@@ -1,4 +1,4 @@
// Type definitions for joi v13.0.1
// Type definitions for joi v13.3.0
// Project: https://github.com/hapijs/joi
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Laurence Dougal Myers <https://github.com/laurence-myers>
@@ -12,6 +12,7 @@
// Anjun Wang <https://github.com/wanganjun>
// Rafael Kallis <https://github.com/rafaelkallis>
// Conan Lai <https://github.com/aconanlai>
// Peter Thorson <https://github.com/zaphoyd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -106,6 +107,13 @@ export interface EmailOptions {
minDomainAtoms?: number;
}
export interface HexOptions {
/**
* hex decoded representation must be byte aligned
*/
byteAligned: boolean;
}
export interface IpOptions {
/**
* One or more IP address versions to validate against. Valid values: ipv4, ipv6, ipvfuture
@@ -512,6 +520,11 @@ export interface NumberSchema extends AnySchema {
* Requires the number to be negative.
*/
negative(): this;
/**
* Requires the number to be a TCP port, so between 0 and 65535.
*/
port(): this;
}
export interface StringSchema extends AnySchema {
@@ -624,7 +637,7 @@ export interface StringSchema extends AnySchema {
/**
* Requires the string value to be a valid hexadecimal string.
*/
hex(): this;
hex(options?: HexOptions): this;
/**
* Requires the string value to be a valid hostname as per RFC1123.
@@ -714,10 +727,15 @@ export interface ArraySchema extends AnySchema {
export interface ObjectSchema extends AnySchema {
/**
* Sets the allowed object keys.
* Sets or extends the allowed object keys.
*/
keys(schema?: SchemaMap): this;
/**
* Appends the allowed object keys. If schema is null, undefined, or {}, no changes will be applied.
*/
append(schema?: SchemaMap): this;
/**
* Specifies the minimum number of keys in the object.
*/
@@ -1101,10 +1119,13 @@ export function ref(key: string, options?: ReferenceOptions): Reference;
export function isRef(ref: any): ref is Reference;
/**
* Get a sub-schema of an existing schema based on a path. Path separator is a dot (.).
* Get a sub-schema of an existing schema based on a `path` that can be either a string or an array
* of strings For string values path separator is a dot (`.`)
*/
export function reach(schema: ObjectSchema, path: string): Schema;
export function reach<T extends Schema>(schema: ObjectSchema, path: string): T;
export function reach(schema: ObjectSchema, path: string[]): Schema;
export function reach<T extends Schema>(schema: ObjectSchema, path: string[]): T;
/**
* Creates a new Joi instance customized with the extension(s) you provide included.
+12
View File
@@ -96,6 +96,12 @@ emailOpts = { minDomainAtoms: num };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
let hexOpts: Joi.HexOptions = null;
hexOpts = { byteAligned: bool };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
let ipOpts: Joi.IpOptions = null;
ipOpts = { version: str };
@@ -602,6 +608,7 @@ numSchema = numSchema.precision(num);
numSchema = numSchema.multiple(num);
numSchema = numSchema.positive();
numSchema = numSchema.negative();
numSchema = numSchema.port();
namespace common {
numSchema = numSchema.allow(x);
@@ -659,6 +666,9 @@ objSchema = Joi.object(schemaMap);
objSchema = objSchema.keys();
objSchema = objSchema.keys(schemaMap);
objSchema = objSchema.append();
objSchema = objSchema.append(schemaMap);
objSchema = objSchema.min(num);
objSchema = objSchema.max(num);
objSchema = objSchema.length(num);
@@ -801,6 +811,7 @@ strSchema = strSchema.guid();
strSchema = strSchema.guid({ version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'] } as Joi.GuidOptions);
strSchema = strSchema.guid({ version: 'uuidv4' });
strSchema = strSchema.hex();
strSchema = strSchema.hex(hexOpts);
strSchema = strSchema.hostname();
strSchema = strSchema.isoDate();
strSchema = strSchema.lowercase();
@@ -969,6 +980,7 @@ description = Joi.describe(schema);
description = schema.describe();
schema = Joi.reach(objSchema, '');
schema = Joi.reach(objSchema, []);
const Joi2 = Joi.extend({ name: '', base: schema });