Hello.
I have a complex viewModel that I need to validate before submiting, but I need not only simple validation rules (such as required field), but also a complex validation that has to do not with html input elements, but with model business rules.
Let me give an example, my viewModel has a timetable property (which represents a study timetable with startHour, endHour, days and trainerId properties), which is an array:
I have a complex viewModel that I need to validate before submiting, but I need not only simple validation rules (such as required field), but also a complex validation that has to do not with html input elements, but with model business rules.
Let me give an example, my viewModel has a timetable property (which represents a study timetable with startHour, endHour, days and trainerId properties), which is an array:
var
viewModel = kendo.observable({
title =
"Example Title"
,
timetable: [
{ startHour:
"11:00"
, endHour:
"13:00"
, days: [ 1 ], trainerId: 1 },
{ startHour:
"12:00"
, endHour:
"14:30"
, days: [ 3, 5 ], trainerId: 2 }
]
});
In this case I need to validate the following:
- Timetable contains at least one element
- Timetable hours don't overlap
This validation is not directly bound to any HTML element, as timetable is a complex property which is rendered using templates.
All kendoValidator examples I've seen work directly with HTML inputs and their attributes.
In other words, is there a possibility to validate the model's business rules, but not HTML inputs?
Thank you.