Skip to content

Commit

Permalink
style: made succeed and fail one-liners
Browse files Browse the repository at this point in the history
  • Loading branch information
GauBen committed Oct 25, 2024
1 parent 93c13a3 commit 64d75b9
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ export interface FormInput<T = unknown> {

// #region Utils

export const succeed = <T>(data: T): Result<T, never> => ({
success: true as const,
data,
});
export const fail = <T>(errors: T): Result<never, T> => ({
success: false as const,
error: errors,
});
export const succeed = <T>(data: T): Result<T, never> => ({ success: true as const, data });
export const fail = <T>(error: T): Result<never, T> => ({ success: false as const, error });

export const failures = {
accept: (accept: string[]) => fail({ code: "accept", accept, message: "Invalid file type" }),
Expand Down

0 comments on commit 64d75b9

Please sign in to comment.