Is there any way to perform custom validations (some kind of hooks) before each update/replace
or insert
and return a message when validation fails? Just like it can be done in ActiveModel
.
I could just write a validating function, but I will need to rewrite all the places where I updated or inserted this model.
AFAIK persistent doesn't have any built-in hooks for validation, this is what I use (combined with yesod's i18n):
And define your validations:
And then in your handler: