@@ -26,7 +26,7 @@ declare namespace Joi {
2626
2727 type BasicType = boolean | number | string | any [ ] | object | null ;
2828
29- type LanguageMessages = Record < string , string | Record < string , string > > ;
29+ type LanguageMessages = Record < string , string | Expression | Record < string , string | Expression > > ;
3030
3131 type PresenceMode = 'optional' | 'required' | 'forbidden' ;
3232
@@ -641,6 +641,10 @@ declare namespace Joi {
641641 render ?: boolean ;
642642 }
643643
644+ interface ExpressionOptions extends ReferenceOptions {
645+ functions : Record < string , ( ...args : unknown [ ] ) => unknown >
646+ }
647+
644648 interface StringRegexOptions {
645649 /**
646650 * optional pattern name.
@@ -1987,6 +1991,8 @@ declare namespace Joi {
19871991 toString ( ) : string ;
19881992 }
19891993
1994+ interface Expression { }
1995+
19901996 type ExtensionBoundSchema = Schema & SchemaInternals ;
19911997
19921998 interface RuleArgs {
@@ -2260,7 +2266,7 @@ declare namespace Joi {
22602266 /**
22612267 * Generates a dynamic expression using a template string.
22622268 */
2263- expression ( template : string , options ?: ReferenceOptions ) : any ;
2269+ expression ( template : string , options ?: ExpressionOptions ) : Expression ;
22642270
22652271 /**
22662272 * Creates a new Joi instance customized with the extension(s) you provide included.
@@ -2324,8 +2330,9 @@ declare namespace Joi {
23242330
23252331 /**
23262332 * Generates a dynamic expression using a template string.
2333+ * @see {@link Root.expression }
23272334 */
2328- x ( template : string , options ?: ReferenceOptions ) : any ;
2335+ x ( template : string , options ?: ExpressionOptions ) : Expression ;
23292336
23302337 // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
23312338 // Below are undocumented APIs. use at your own risk
0 commit comments