Open dziraf opened 3 years ago
Prisma doesn't provide a similar validation mechanism as Sequelize and TypeORM at the moment, but we have several issues that are related to this. It would be great if you could add a comment to the issues that seem most relevant to your use case and I'll try to draw attention to them internally 🙂
Ideally, we would like to be able to validate forms like we do in other adapters:
class-validator
We need to find out if we are able to define such validations in Prisma as well and if yes, check whether error data contains enough information to display such error to the end user.
Currently, the adapter attempts to save whatever is sent from the form and the query can fail against SQL constraints, but the error displayed to the user is generic and says only that there were errors when saving the record.
Before this is fully researched and implemented, form validations have to be custom-made, example:
With this, there will be a proper error message displayed under
someRequiredInput
field in the form if it isn't defined. This is abefore
hook which should be used innew
andedit
actions.