Skip to content

Commit 0de13c1

Browse files
authored
Create index.d.ts (#25)
1 parent 2813756 commit 0de13c1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

index.d.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
declare module 'joi-password-complexity'{
2+
import { ValidationError } from '@hapi/joi';
3+
4+
export type ComplexityOptions = {
5+
min?: number,
6+
max?: number,
7+
lowerCase?: number,
8+
upperCase?: number,
9+
numeric?: number,
10+
symbol?: number,
11+
requirementCount?: number,
12+
};
13+
14+
interface ValidationErrorItem {
15+
message: string;
16+
type: string;
17+
path: string[];
18+
options?: ValidationOptions;
19+
context?: Context;
20+
}
21+
22+
interface ValidationError extends Error {
23+
details: ValidationErrorItem[];
24+
annotate(): string;
25+
_object: any;
26+
}
27+
28+
export type ComplexityObject = {
29+
type: string,
30+
base: string,
31+
messages: {
32+
'passwordComplexity.tooShort': string,
33+
'passwordComplexity.tooLong': string,
34+
'passwordComplexity.lowercase': string,
35+
'passwordComplexity.uppercase': string,
36+
'passwordComplexity.numeric': string,
37+
'passwordComplexity.symbol': string,
38+
'passwordComplexity.requirementCount': string,
39+
},
40+
validate: (value: string) => {
41+
value: string
42+
error?: ValidationError,
43+
};
44+
};
45+
46+
export default function (options: ComplexityOptions, label?: string): ComplexityObject;
47+
}

0 commit comments

Comments
 (0)