Skip to content

Commit 38bd64a

Browse files
authored
Merge pull request #65 from akazakou/fix/fix-wrong-typings
Fix wrong TypeScript types
2 parents 11a600a + 1bbfc55 commit 38bd64a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

index.d.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** type declaration for fastest-validator */
22

3-
declare interface ValidationRuleObject {
3+
interface ValidationRuleObject {
44
type: string;
55
optional?: boolean;
66
empty?: boolean;
@@ -23,39 +23,46 @@ declare interface ValidationRuleObject {
2323
convert?: boolean;
2424
items?: string;
2525
props?: ValidationSchema;
26-
check?: (value: any, schema: ValidationSchema) => boolean | ValidationResult;
26+
check?: (value: any, schema: ValidationSchema) => true | ValidationResult;
2727
}
2828

29-
declare type ValidationRule = ValidationRuleObject | ValidationRuleObject[] | string;
29+
type ValidationRule = ValidationRuleObject | ValidationRuleObject[] | string;
3030

31-
declare interface ValidationSchema {
31+
interface ValidationSchema {
3232
[key: string]: ValidationRule;
3333
}
3434

3535

36-
declare interface ValidationError {
36+
interface ValidationError {
3737
type: string;
3838
field: string;
3939
message: string;
4040
expected?: any;
4141
actual?: any;
4242
}
4343

44-
declare type ValidationResult = ValidationError[];
45-
declare type ValidationObject = { [key: string]: any };
44+
type ValidationResult = ValidationError[];
45+
type ValidationObject = { [key: string]: any };
4646

47-
declare class Validator {
47+
class Validator {
4848
constructor(opts?: any);
4949

5050
add(type: string, fn: any): void;
5151

5252
makeError(type: string, expected: any, actual: any): ValidationResult;
5353

54-
compile(schema: ValidationSchema): (object: ValidationObject) => boolean | ValidationResult;
54+
compile(schema: ValidationSchema | ValidationSchema[]): (object: ValidationObject) => boolean | ValidationResult;
5555

5656
validate(obj: ValidationObject, schema: ValidationSchema): boolean | ValidationResult;
5757
}
5858

59-
declare module "fastest-validator" {
60-
export = Validator;
59+
export {
60+
ValidationRuleObject,
61+
ValidationRule,
62+
ValidationSchema,
63+
ValidationError,
64+
ValidationResult,
65+
ValidationObject,
6166
}
67+
68+
export = Validator

0 commit comments

Comments
 (0)