FlowingCode / backend-core

Commons utilities for back-end enterprise features
Apache License 2.0
4 stars 1 forks source link

Expose validators to the presentation layer #52

Closed javier-godoy closed 2 years ago

javier-godoy commented 2 years ago

From the presentation layer I want to run service validations before actually saving an item, so that I'm able to display validation errors in advance.

ngonzalezpazFC commented 2 years ago

This feature could be really useful to, as you said, present errors to the user in a nice way. It could be helpful that the validation mechanism could return a list of validation errors like services that implement ValidationSupportdoes, but I can't see where the validations should be triggered.

javier-godoy commented 2 years ago

I can't see where the validations should be triggered.

If you are using Binder, they can be bean-level validation with Binder. Otherwise, just call the validation when you see fit, and you'll known whether the bean is valid (e.g. if it's "insertable") without actually invoking the service operation.

ngonzalezpazFC commented 2 years ago

That is a good option if Vaadin is being used, but my comment was pointed to that Commons Backend can be used with a different frontend technology