This is a migrated thread and some comments may be shown as answers.

How to prevent Foreign relational model validation

1 Answer 6 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
riz
Top achievements
Rank 1
riz asked on 24 May 2018, 04:39 PM
I am using Kendo MVC grids as provided in your examples and linking them directly to my domain models. The problem I am facing is that when I am trying to edit/create a certain Model, not only its primitive properties, but also any of the other Models' properties it contains are validated. For example, if I have a School  model, and it contains a Country (which i can select via a populated dropdown), it should only validate School properties such as Name, etc. But it's unreasonable if it also tries to validate all the properties under Country.  I don't care in my form if Country has all the required fields. All I care about is populating the Country dropdown with Id, Name for Value and Text. When I look at the Request.Form, I can clearly see that its trying to bind all the fields that start with "models" and that includes all the relational models' properties. 

Please tell me a workaround/solution and also please fix your documentation or your library to not enable this by default as it is a waste of time. I have been searching how to fix this for a long time and it's very frustrating that these basic cases are not well thought out.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 May 2018, 12:50 PM
Hi,

Properties for nested object will be required if they are not nullable. If you are seeing the validation even if the properties are nullable, please share the exact model that you are using and the configuration of the Grid in question, so we can see what else could be causing the behavior.


Best Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
riz
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or