Skip to content
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

Datagrid FluentValidationHandler support unavailable or undocumented #4787

Closed
dsmiller95 opened this issue May 26, 2023 · 1 comment
Closed
Assignees
Labels
Type: Bug 🐞 Something isn't working
Milestone

Comments

@dsmiller95
Copy link

dsmiller95 commented May 26, 2023

Describe the bug
The datagrid ValidationsHandlerType does not appear to be respected when set to FluentValidationHandler. The validation handler type defined on a DataGrid is not used when validating columns during edit/create flows. Specifically this prevents the use of FluentValidationHandler on the top-level datagrid.

To Reproduce

minimal code example:
https://github.com/dsmiller95/data-grid-fluent-validation-example/blob/fe93ed4ac1a4211a3ab490f1f4d8946a789a801f/DataGridFluentValidation/Pages/DataGridPage.razor

Steps to reproduce the behavior:

  1. Follow setup steps for Blazorise.FluentValidation : https://blazorise.com/docs/extensions/fluent-validation
  2. Copy example for DataGrid validation : https://blazorise.com/docs/extensions/datagrid/validations
  3. Set ValidationsHandlerType="typeof(FluentValidationHandler)"
  4. Implement EmployeeValidator : AbstractValidator<Employee>
  5. Run the app, edit the Employee row
  6. Observe that the validations are not applied

Expected behavior
The validations in EmployeeValidator are checked over the data before saving, or while editing.

Screenshots
Data grid allows saving an employee with no name, when a FluentValidator is defined to explicitly deny this:
image

Additional context
I believe the ValidationsHandlerType is completely ignored in this use case. In this revision of the code , we set ValidationsHandlerType="typeof(TestValidationHandler)". TestValidationHandler throws an exception on all methods, but no exceptions are thrown when running the app. And a breakpoint set in TestValidationHandler will not be hit.

This may be intentional, but the documentation implies it is not, as I have not overriden the HandlerType anywhere else in the code:

Attributes
DataGrid

Name Description
ValidationsHandlerType Defines the default handler type that will be used by the validation, unless it is overriden by Validation.HandlerType property.
@dsmiller95 dsmiller95 added the Type: Bug 🐞 Something isn't working label May 26, 2023
@stsrki
Copy link
Collaborator

stsrki commented May 26, 2023

Thanks for reporting it.

You're right. It seems that it always fallbacks to DataAnnotationValidationHandler internally in our _DataGridCell component.

image


We will fix it for the next maintenance release.

@stsrki stsrki added this to the 1.2 support milestone May 26, 2023
@stsrki stsrki self-assigned this May 26, 2023
@stsrki stsrki closed this as completed May 27, 2023
@stsrki stsrki added this to Support Aug 3, 2024
@stsrki stsrki moved this to ✔ Done in Support Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants