I'm having a validation difficulty. I have View
that sends to Controller
information, where view
is used knockoutjs
, however it has time it sends null
or "null"
or "NaN"
or "false"
or "0"
, I have not seen "undefined"
yet!
Script part knockoutjs
when 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: do I have to do something generic or do I have to check it one at a time?