Created
February 12, 2013 01:44
-
-
Save andylind/4759407 to your computer and use it in GitHub Desktop.
This C# class can be used to return both a result and a validation value. In some cases it may also make sense to include an optional validation error message in the class.
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
// Used when both a result and a validation value are needed | |
public class ValidatedResponse<T> | |
{ | |
private readonly bool isOk; | |
public T Item { get; private set; } | |
public ValidatedResponse(bool isOk, T item) | |
{ | |
this.isOk = isOk; | |
Item = item; | |
} | |
public bool IsNotValid() | |
{ | |
return !this.isOk; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment