Example of compound iteration when performing validation against loosely typed data
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
public List<string> Validate(IDictionary<string, object> data, List<Field> mandatoryFields) | |
{ | |
var errors = new List<string>(); | |
foreach (var field in mandatoryFields) | |
{ | |
if (!data.Keys.Contains(field.Identifier)) | |
{ | |
errors.add(String.Format("The {0} field is required", field.Identifier); | |
} | |
} | |
return errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment