mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-09 03:30:09 +00:00
fix(@hapi/joi): fix extend typings (#42297)
This commit is contained in:
@@ -1012,11 +1012,18 @@ const Joi3 = Joi.extend({
|
||||
asd: {
|
||||
args: [
|
||||
{
|
||||
name: 'allowFalse'
|
||||
name: 'allowFalse',
|
||||
ref: true,
|
||||
assert: Joi.boolean(),
|
||||
}
|
||||
],
|
||||
method(allowFalse) {
|
||||
this.$_createError(str, {}, {}, {}, {});
|
||||
method(allowFalse: boolean) {
|
||||
return this.$_addRule({
|
||||
name: 'asd',
|
||||
args: {
|
||||
allowFalse,
|
||||
}
|
||||
});
|
||||
},
|
||||
validate(value: boolean, helpers, params, options) {
|
||||
if (value || params.allowFalse && !value) {
|
||||
|
||||
11
types/hapi__joi/index.d.ts
vendored
11
types/hapi__joi/index.d.ts
vendored
@@ -679,6 +679,13 @@ declare namespace Joi {
|
||||
|
||||
type SchemaFunction = (schema: Schema) => Schema;
|
||||
|
||||
interface AddRuleOptions {
|
||||
name: string;
|
||||
args?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
interface SchemaInternals {
|
||||
/**
|
||||
* Parent schema object.
|
||||
@@ -693,7 +700,7 @@ declare namespace Joi {
|
||||
/**
|
||||
* Adds a rule to current validation schema.
|
||||
*/
|
||||
$_addRule(rule: string | ExtensionRule): Schema;
|
||||
$_addRule(rule: string | AddRuleOptions): Schema;
|
||||
|
||||
/**
|
||||
* Internally compiles schema.
|
||||
@@ -1756,7 +1763,7 @@ declare namespace Joi {
|
||||
interface RuleArgs {
|
||||
name: string;
|
||||
ref?: boolean;
|
||||
assert?: (value: any) => boolean;
|
||||
assert?: ((value: any) => boolean) | AnySchema;
|
||||
message?: string;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user