-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
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
Update ActiveModelBehavior
API allowing custom validation logic
#161
Comments
Basically each Entity should be able to perform their own validation logic defined inside the entity file. Rather than relaying on the user to perform the validation. However, SeaORM current didn't offer any way to perform validation in Entity level. |
I also think there is a few missing methods: // change 1)
// change the return type to be `Result<T, E>`
// change 2)
// add missing method:
fn after_delete(self) -> Result<Self, Error> { ... }
// change 1)
// we need to change the *_save() to indicate if this is inserting or updating entities:
fn after_save(self, is_insert: bool) -> Result<Self, Error> { ... }
fn before_save(self, is_insert: bool) -> Result<Self, Error> { ... }
// or we add these new methods instead changing *_save() methods.
fn before_insert(self) -> Result<Self, Error> { ... }
fn after_insert(self) -> Result<Self, Error> { ... } here is another changes that we need to discuss further:
|
Yes!
Agree
I think this is reasonable, handle insert / update in single |
I think we should if we are executing this
Good suggestions! |
Issue raised by @MuhannadAlrusayni, thank you so much for the suggestions!
The text was updated successfully, but these errors were encountered: