Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Created January 21, 2014 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyond-code-github/8548694 to your computer and use it in GitHub Desktop.
Save beyond-code-github/8548694 to your computer and use it in GitHub Desktop.
Example of compound iteration when performing validation against loosely typed data
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