mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-09 03:30:09 +00:00
[@hapi/joi] fix the joi.assert() and joi.attempt() types (#38993)
* [@hapi/joi] fix the joi.assert() and joi.attempt() types * Update tests * Improve types
This commit is contained in:
committed by
Armando Aguirre
parent
306afbe5c0
commit
a83bc68922
@@ -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);
|
||||
|
||||
8
types/hapi__joi/index.d.ts
vendored
8
types/hapi__joi/index.d.ts
vendored
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user