Skip to content

Commit

Permalink
refactor(lib/validate-interface): Rename SuccessResult.result to value
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespascoe committed Jan 10, 2018
1 parent 98f8957 commit e971e1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function conformsTo<T>(validator: Validator<T>, optionsOrNext?: IValidati
return errors.concat(result.addPathNode(new KeyPathNode(key)).errors);
}

partiallyValidated[key] = result.result;
partiallyValidated[key] = result.value;
return errors;
}, [] as ValidationError[]);

Expand Down Expand Up @@ -261,7 +261,7 @@ export function eachItem<T>(assertion: (arg: any) => ValidationResult<T>, next?:
);
}

const mapped = (results as SuccessResult<T>[]).map(result => result.result);
const mapped = (results as SuccessResult<T>[]).map(result => result.value);

return next ? next(mapped) : success(mapped);
};
Expand Down
6 changes: 3 additions & 3 deletions lib/validation-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ErrorResult {

export interface SuccessResult<T> {
readonly success: true;
readonly result: T;
readonly value: T;
}


Expand All @@ -100,6 +100,6 @@ export function errorFromException(err: any): ErrorResult {
}


export function success<T>(result: T): SuccessResult<T> {
return {success: true, result};
export function success<T>(value: T): SuccessResult<T> {
return {success: true, value};
}

0 comments on commit e971e1a

Please sign in to comment.