3
I’m having a validation difficulty. I have a View
that sends to the Controller
information, where in view
is used knockoutjs
, but there is time that he sends a null
or "null"
or "NaN"
or "false"
or "0"
, I just didn’t see "undefined"
yet!
Part of Script knockoutjs
when you have no information:
var InternalAuditRecordTopicEmpty = {
InternalAuditRecordTopicID: 0,
InternalAuditRecordID: 0,
Name:'',
Order:9999,
Request:'',
NonComformityType:'',
Comformity:'',
OM:'',
Observation:'',
Evidences:'',
};
My Controller:
if (criticalAnalysisRecord.InternalAuditRecordTopics.ElementAt(i).OM == "false"
|| criticalAnalysisRecord.InternalAuditRecordTopics.ElementAt(i).OM == "0")
criticalAnalysisRecord.InternalAuditRecordTopics.ElementAt(i).OM = null;
if (criticalAnalysisRecord.InternalAuditRecordTopics.ElementAt(i).OM == null && iscontrol)
{ error =true; }
My question is: is there any way I can do something generic or have to check one by one?