diff --git a/types/hapi__joi/hapi__joi-tests.ts b/types/hapi__joi/hapi__joi-tests.ts index 640907f1db..89a459b5b1 100644 --- a/types/hapi__joi/hapi__joi-tests.ts +++ b/types/hapi__joi/hapi__joi-tests.ts @@ -961,13 +961,22 @@ schema = Joi.compile(schemaMap); Joi.assert(obj, schema); Joi.assert(obj, schema, str); +Joi.assert(obj, schema, str, validOpts); Joi.assert(obj, schema, err); +Joi.assert(obj, schema, err, validOpts); +Joi.assert(obj, schema, validOpts); Joi.assert(obj, schemaLike); -Joi.attempt(obj, schema); -Joi.attempt(obj, schema, str); -Joi.attempt(obj, schema, err); -Joi.attempt(obj, schemaLike); +{ + let value = { username: 'example', password: 'example' }; + value = Joi.attempt(obj, schema); + value = Joi.attempt(obj, schema, str); + value = Joi.attempt(obj, schema, str, validOpts); + value = Joi.attempt(obj, schema, err); + value = Joi.attempt(obj, schema, err, validOpts); + value = Joi.attempt(obj, schema, validOpts); + value = Joi.attempt(obj, schemaLike); +} ref = Joi.ref(str, refOpts); ref = Joi.ref(str); diff --git a/types/hapi__joi/index.d.ts b/types/hapi__joi/index.d.ts index 9f3c1e4e45..71b368c548 100644 --- a/types/hapi__joi/index.d.ts +++ b/types/hapi__joi/index.d.ts @@ -1961,16 +1961,18 @@ declare namespace Joi { * @param schema - the schema object. * @param message - optional message string prefix added in front of the error message. may also be an Error object. */ - assert(value: any, schema: SchemaLike, message?: string | Error, options?: ValidationOptions): void; + assert(value: any, schema: SchemaLike, options?: ValidationOptions): void; + assert(value: any, schema: SchemaLike, message: string | Error, options?: ValidationOptions): void; /** - * Validates a value against a schema and throws if validation fails. + * Validates a value against a schema, returns valid object, and throws if validation fails. * * @param value - the value to validate. * @param schema - the schema object. * @param message - optional message string prefix added in front of the error message. may also be an Error object. */ - attempt(value: any, schema: SchemaLike, message?: string | Error, options?: ValidationOptions): void; + attempt(value: any, schema: SchemaLike, options?: ValidationOptions): any; + attempt(value: any, schema: SchemaLike, message: string | Error, options?: ValidationOptions): any; cache: CacheConfiguration;