Skip to content

Commit 910bfce

Browse files
authored
Merge pull request #38 from nullgr/release/1.3.7
Release/1.3.7
2 parents e222298 + 982ee45 commit 910bfce

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

build/index.d.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ type FieldsDescription = {
1010
[key: string]: RuleData | RuleData[];
1111
};
1212

13+
type updaterFunction<T> = (prevState: Readonly<T>) => T;
14+
1315
export default class Validator<State> {
1416
constructor(fields: FieldsDescription, validationStorageName?: string);
1517

@@ -25,18 +27,14 @@ export default class Validator<State> {
2527
addValidation(state: State, showErrorsOnStart?: boolean): Readonly<State>;
2628

2729
validate(
28-
stateUpdates: (prevState: Readonly<State>) => State,
30+
stateUpdates?: Partial<State> | updaterFunction<State> | null,
2931
showErrors?: boolean
3032
): ((prevState: Readonly<State>) => State);
3133

32-
validate(
33-
stateUpdates?: { [key in keyof State]: any } | null,
34-
showErrors?: boolean
35-
): Readonly<State>;
36-
37-
getErrors(state: State): { [key in keyof State]: any };
34+
getErrors(state: State): { [key in keyof State]: string };
3835

3936
isFormValid(state: State): boolean;
4037

4138
isFieldValid(state: State, fieldName: string): boolean;
4239
}
40+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-validation-utils",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"description": "Validate react form components, based on their state",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

types/index.d.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ type FieldsDescription = {
1010
[key: string]: RuleData | RuleData[];
1111
};
1212

13+
type updaterFunction<T> = (prevState: Readonly<T>) => T;
14+
1315
export default class Validator<State> {
1416
constructor(fields: FieldsDescription, validationStorageName?: string);
1517

@@ -25,18 +27,14 @@ export default class Validator<State> {
2527
addValidation(state: State, showErrorsOnStart?: boolean): Readonly<State>;
2628

2729
validate(
28-
stateUpdates: (prevState: Readonly<State>) => State,
30+
stateUpdates?: Partial<State> | updaterFunction<State> | null,
2931
showErrors?: boolean
3032
): ((prevState: Readonly<State>) => State);
3133

32-
validate(
33-
stateUpdates?: { [key in keyof State]: any } | null,
34-
showErrors?: boolean
35-
): Readonly<State>;
36-
37-
getErrors(state: State): { [key in keyof State]: any };
34+
getErrors(state: State): { [key in keyof State]: string };
3835

3936
isFormValid(state: State): boolean;
4037

4138
isFieldValid(state: State, fieldName: string): boolean;
4239
}
40+

0 commit comments

Comments
 (0)