We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors and Context are typed as Array:
Errors
Context
Array
export interface Context extends ReadonlyArray<ContextEntry> {} export interface Errors extends Array<ValidationError> {} export type Validation<A> = Either<Errors, A>
Errors should be typed as NonEmptyArray, since the absence of errors would constitute a success (either.Right):
NonEmptyArray
either.Right
export interface Errors extends NonEmptyArray<ValidationError> {} export type Validation<A> = Either<Errors, A>
See also https://zio.github.io/zio-prelude/docs/functionaldatatypes/validation
Context should be typed as ReadonlyNonEmptyArray since at least one context should exist for an error:
ReadonlyNonEmptyArray
export interface Context extends ReadonlyNonEmptyArray<ContextEntry> {}
See pull request
The solution simplifies error handling since the user can rely on the fact that at least one error with at least one context is present.
–
The text was updated successfully, but these errors were encountered:
feat: Type Errors as NonEmptyArray (gcanti#670)
f584c79
feat: Type Context as NonEmptyArray (gcanti#670)
5c4eed1
Successfully merging a pull request may close this issue.
🚀 Feature request
Current Behavior
Errors
andContext
are typed asArray
:Desired Behavior
Errors
should be typed asNonEmptyArray
, since the absence of errors would constitute a success (either.Right
):See also https://zio.github.io/zio-prelude/docs/functionaldatatypes/validation
Context
should be typed asReadonlyNonEmptyArray
since at least one context should exist for an error:Suggested Solution
See pull request
Who does this impact? Who is this for?
The solution simplifies error handling since the user can rely on the fact that at least one error with at least one context is present.
Describe alternatives you've considered
–
Additional context
–
Your environment
The text was updated successfully, but these errors were encountered: