This commit is contained in:
@@ -77,6 +77,44 @@ namespace AyaNova.DataList
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
//make sure the template parses and all the fields specified are really existant
|
||||
//this is more for dev errors or api users becuase the client shouldn't generate bad templates
|
||||
public bool ValidateTemplate(string template)
|
||||
{
|
||||
try
|
||||
{
|
||||
//parse the template
|
||||
var jtemplate = JObject.Parse(template);
|
||||
var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>();
|
||||
var miniFields = ((JArray)jtemplate["mini"]).ToObject<string[]>();
|
||||
|
||||
foreach (string s in fullFields)
|
||||
{
|
||||
AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string s in miniFields)
|
||||
{
|
||||
AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user