Skip to content

Commit b95a8be

Browse files
committed
Changed 30 solution
1 parent 7d37775 commit b95a8be

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/06-challenges/30-form-validator.solution.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { expect, it } from "vitest";
22
import { Equal, Expect } from "../helpers/type-utils";
33

4-
type ValidatorsBase = Record<string, (value: string) => string | void>;
5-
6-
type ValidatorConfig<ValidatorKey> = Record<string, Array<ValidatorKey>>;
7-
84
const makeFormValidatorFactory =
9-
<TValidators extends ValidatorsBase>(validators: TValidators) =>
10-
<TInput extends ValidatorConfig<keyof TValidators>>(config: TInput) => {
11-
return (
12-
values: Record<keyof TInput, string>
13-
): Record<keyof TInput, string | undefined> => {
14-
const errors = {} as any;
5+
<TValidatorKeys extends string>(
6+
validators: Record<TValidatorKeys, (value: string) => string | void>
7+
) =>
8+
<TObjKeys extends string>(
9+
config: Record<TObjKeys, Array<TValidatorKeys>>
10+
) => {
11+
return (values: Record<TObjKeys, string>) => {
12+
const errors = {} as Record<TObjKeys, string | undefined>;
1513

1614
for (const key in config) {
1715
for (const validator of config[key]) {

0 commit comments

Comments
 (0)