Closed diogob closed 2 years ago
I like the idea of having a separate error for this use case. The current InputError is very elegant for most use cases. It would be weird to have to pass a list to it.
I'm also fine with having a separate InputErrors
that would handle this case.
@machour I have just published the 0.3.0 to npm. The package.json from remix-forms is bound to >= 0.2.0 so you should be able to update the remix-domains dependency on your project and use the new InputErrors
error and pass a list of {message: string, path: string}
.
The interface is described in the corresponding README section.
Tested and validated, thank you so much @diogob !
Just an update from the future! You can throw a list of errors now with:
const fn = composable(() => {
throw new ErrorList([
new Error('Oops'),
new InputError('Required', ['name'])
])
})
There are use cases such as this one, where throwing a single exception with multiple input errors is desirable. We should add a custom error constructor for that. Perhaps just have a plural
InputErrors
that will take a non-empty list as argument. If we are fine breaking backwards compatibility we could also just change theInputError
type.