Skip to content

Commit 318a3d4

Browse files
committed
fix: added missing return types
1 parent 9640bca commit 318a3d4

File tree

8 files changed

+39
-14
lines changed

8 files changed

+39
-14
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
"type": "git",
6161
"url": "git://github.com/ziccardi/json-data-validator.git"
6262
}
63-
}
63+
}

src/rules/builders/CompositeRuleBuilder.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
import {RuleConfig} from '../../config/RuleConfig';
22

3+
export interface CompositeRuleBuilderInterfaceStart {
4+
withSubRule: (rule: RuleConfig) => CompositeRuleBuilderInterfaceEnd;
5+
}
6+
7+
export interface CompositeRuleBuilderInterfaceEnd {
8+
withSubRule: (rule: RuleConfig) => CompositeRuleBuilderInterfaceEnd;
9+
build: () => RuleConfig;
10+
}
11+
312
export const builder = {
4-
any: () => {
13+
any: (): CompositeRuleBuilderInterfaceStart => {
514
const subRules: RuleConfig[] = [];
615

7-
const withSubRule = (rule: RuleConfig) => {
16+
const withSubRule = (
17+
rule: RuleConfig
18+
): CompositeRuleBuilderInterfaceEnd => {
819
subRules.push(rule);
920
return {withSubRule, build};
1021
};
1122

12-
const build = () => ({
23+
const build = (): RuleConfig => ({
1324
type: 'COMPOSITE',
1425
algorithm: 'any',
1526
subRules,
1627
});
1728

1829
return {withSubRule};
1930
},
20-
all: () => {
31+
all: (): CompositeRuleBuilderInterfaceStart => {
2132
const subRules: RuleConfig[] = [];
2233

23-
const withSubRule = (rule: RuleConfig) => {
34+
const withSubRule = (
35+
rule: RuleConfig
36+
): CompositeRuleBuilderInterfaceEnd => {
2437
subRules.push(rule);
2538
return {withSubRule, build};
2639
};
2740

28-
const build = () => ({
41+
const build = (): RuleConfig => ({
2942
type: 'COMPOSITE',
3043
algorithm: 'all',
3144
subRules,

src/rules/builders/ExactValueBuilder.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import {RuleConfig} from '../../config/RuleConfig';
2+
13
export const builder = {
2-
withValue: (value: string | number) => ({type: 'EXACT_VALUE', value}),
3-
withPathAndValue: (path: string, value: string | number) => ({
4+
withValue: (value: string | number): RuleConfig => ({
5+
type: 'EXACT_VALUE',
6+
value,
7+
}),
8+
withPathAndValue: (path: string, value: string | number): RuleConfig => ({
49
type: 'EXACT_VALUE',
510
path,
611
value,

src/rules/builders/IsInBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import {RuleConfig} from '../../config/RuleConfig';
2+
13
export const builder = {
2-
withValues: (...values: string[]) => ({
4+
withValues: (...values: string[]): RuleConfig => ({
35
type: 'isIn',
46
values: values.join(),
57
}),
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as LengthRule from '../LengthRule';
2+
import {RuleConfig} from '../../config/RuleConfig';
23

34
export const builder = {
4-
withLength: (length: number) => ({type: LengthRule.NAME, length}),
5+
withLength: (length: number): RuleConfig => ({type: LengthRule.NAME, length}),
56
};
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {RuleConfig} from '../../config/RuleConfig';
2+
13
export const builder = {
2-
withPattern: (pattern: string) => ({type: 'matches', pattern}),
4+
withPattern: (pattern: string): RuleConfig => ({type: 'matches', pattern}),
35
};

src/rules/builders/RequiredValueBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import {RuleConfig} from '../../config/RuleConfig';
2+
13
export const builder = {
2-
required: (path?: string) => ({
4+
required: (path?: string): RuleConfig => ({
35
type: 'REQUIRED',
46
path,
57
}),

0 commit comments

Comments
 (0)