Skip to content

Commit

Permalink
style: rename parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Khasms committed Jan 24, 2022
1 parent e4d60dc commit cc0bb7c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/validators/MapValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export class MapValidator<K, V> extends BaseValidator<Map<K, V>> {
return Reflect.construct(this.constructor, [this.keyValidator, this.valueValidator, this.constraints]);
}

protected handle(values: unknown): Result<Map<K, V>, ValidationError | AggregateError> {
if (!(values instanceof Map)) {
return Result.err(new ValidationError('MapValidator', 'Expected a map', values));
protected handle(value: unknown): Result<Map<K, V>, ValidationError | AggregateError> {
if (!(value instanceof Map)) {
return Result.err(new ValidationError('MapValidator', 'Expected a map', value));
}

const errors: Error[] = [];
const transformed = new Map<K, V>();

for (const [key, value] of values.entries()) {
for (const [key, val] of value.entries()) {
const keyResult = this.keyValidator.run(key);
const valueResult = this.valueValidator.run(value);
const valueResult = this.valueValidator.run(val);
const results = [keyResult, valueResult].filter((result) => result.isErr());
if (results.length === 0) transformed.set(keyResult.value!, valueResult.value!);
else errors.push(...results.map((result) => result.error!));
Expand Down

0 comments on commit cc0bb7c

Please sign in to comment.