Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to use generics with the compile method #146

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,11 @@ declare module "fastest-validator" {
| ValidationRuleObject
| ValidationRuleObject[]
| ValidationRuleName;

/**
* Definition for validation schema based on validation rules
*/
interface ValidationSchema {
type ValidationSchema<T = any> = {
/**
* Object properties which are not specified on the schema are ignored by default.
* If you set the $$strict option to true any additional properties will result in an strictObject error.
Expand All @@ -733,12 +733,12 @@ declare module "fastest-validator" {
* @default false
*/
$$root?: boolean;

} & {
/**
* List of validation rules for each defined field
*/
[key: string]: ValidationRule | undefined | any;
}
[key in keyof T]: ValidationRule | undefined | any;
};

/**
* Structure with description of validation error message
Expand Down Expand Up @@ -897,8 +897,8 @@ declare module "fastest-validator" {
* @param {ValidationSchema | ValidationSchema[]} schema Validation schema definition that should be used for validation
* @return {(value: any) => (true | ValidationError[])} function that can be used next for validation of current schema
*/
compile(
schema: ValidationSchema | ValidationSchema[]
compile<T = any>(
schema: ValidationSchema<T> | ValidationSchema<T>[],
): (value: any) => true | ValidationError[];

/**
Expand Down