|
using ZipMyCode.Properties;
using ZipMyCode.UI.Mvvm.Validation;
namespace ZipMyCode.UI.ExcludeItem
{
/// <summary>
/// Rule validating that a string is not null or empty.
/// </summary>
class NotNullOrEmptyValidationRule : IValidationRule
{
/// <summary>
/// Validates a value.
/// </summary>
/// <param name="value">The value to validate.</param>
/// <returns>true if validation is successful; otherwise false.</returns>
public bool Validate(object value)
{
string valueText = value as string;
if (string.IsNullOrEmpty(valueText))
{
ErrorMessage = Resources.NotNullValidationRule_Error;
return false;
}
ErrorMessage = string.Empty;
return true;
}
/// <summary>
/// Gets the error message if validation fails; otherwise an empty string ("").
/// </summary>
public string ErrorMessage { get; private set; }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Got my first computer in the 90's and loved it even though it sounded like a coffeemaker.
Now getting paid for designing cool applications, and drinks the coffee instead of listening to it being made.