Created
May 25, 2019 11:30
-
-
Save harishrathi/1a82687d8817b4df0668695638297a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ValidationConfiguration() | |
{ | |
var fields = this.Fields.Select(x => x.Key).ToList(); | |
var duplicateFields = fields.GroupBy(x => x) | |
.Where(g => g.Count() > 1) | |
.Select(y => y.Key) | |
.ToList(); | |
if (duplicateFields.Count > 0) | |
{ | |
var result = string.Join(',', duplicateFields); | |
throw new MyProgramException("ngx form : duplicate fields: " + result); | |
} | |
var properties = typeof(TEntity).GetProperties().ToList(); | |
if (properties.Count == this.Fields.Count) | |
{ | |
return; | |
} | |
if (properties.Count > this.Fields.Count) | |
{ | |
var propertyNames = properties.Select(x => x.Name).ToList(); | |
var result = string.Join(',', propertyNames.Where(x => !fields.Contains(x))); | |
throw new MyProgramException("ngx form : unconfigured properties " + result); | |
} | |
if (this.Fields.Count > properties.Count) | |
{ | |
var propertyNames = properties.Select(x => x.Name).ToList(); | |
var result = string.Join(',', fields.Where(x => !propertyNames.Contains(x))); | |
throw new MyProgramException("ngx form : missing properties: " + result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment