Hello,
I have a pupil entity implementing IDataErrorInfo:
Now the exact same rules I want to validate against the Lastname, Gender, Street, City, Postal and Phone.
Do I really have to repeat all that ? Using ValidationRule class would be better but then I
can not handle disabling/enabling buttons via ICommand.
...
#region Validation Rules
private string ValidateFirstName()
{
if (IsStringMissing(this.FirstName))
return ErrorStrings.General_Error_StringMustNotBeEmpty;
if (IsStringTooLong(this.FirstName))
return ErrorStrings.General_Error_StringTooLong50Maximum;
return null;
}
private static bool IsStringMissing(string value)
{
return String.IsNullOrEmpty(value) || value.Trim() == String.Empty;
}
private static bool IsStringTooLong(string value)
{
return value.Length > 50;
}
#endregion