Suggestion - bind validation errors from viewmodel to sfDataForm

Hi,

I have noticed that utility of SfDataForm is somewhat diminished with the way it's validation was realized. 

  1. It's hard to do custom validation.
  2. It's not aligned with MVVM architecture, where validation should be performed in viewmodel.

I would suggest to, instead of having the form perform validation, have it delegate validation to other parties (viewmodel for example), and then bind to observable object that contains errors for each property.  Object to bind to could have the standard IDataErrorInfo contract, providing all the necessary events and data.

SfData form could provide following:

  1. Bindable property for observable error list where errors can be associated with property names
  2. View section for errors not associated with any property (or associated with multiple properties)
  3. A Command with property name parameter to bind validation logic for single property
  4. A Command without parameters to bind validation logic for the whole data object.

Soo, that's the general idea, I think it would make the component much easier to work with.

And if there is a way to have viewmodel perform the validation right now, please let me know. Thanks!




1 Reply

VM Vidyalakshmi Mani Syncfusion Team August 13, 2024 12:32 PM UTC

Hi Miljan,


Thank you for contacting us. The MAUI SfDataForm control supports validation through Data Annotations and the INotifyDataErrorInfo interface. This interface allows you to track and retrieve a list of all validation errors on your data-bound properties. We’ve prepared a simple sample to illustrate this solution. Please check the attached sample for your reference.


If this approach doesn’t fully meet your needs, please share more information about your requirements. This will help us better understand your needs and provide a more effective solution.


Regards,

Vidyalakshmi M.



Attachment: MauiDataForm_7b086e88.zip

Loader.
Up arrow icon