Unable to pass Parameter Value in CustomValidation Attribute

  • Thread starter Thread starter ID GO
  • Start date Start date
I

ID GO

Guest
Unable to pass Parameter Value in CustomValidation Attribute


public string Test { get; set; } = "ValidateSpecialCharacters";

[CustomValidation(typeof(ValidationTextBox), Test)]
public string GeneralDescription
{
get => _generalDescription;
set
{
SetValue(ref _generalDescription, value);
TestBorderBrush = ValidationDictionaryCollection["GeneralDescription"] != string.Empty
? new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0x00, 0x00))
: new SolidColorBrush(Color.FromArgb(102, 0, 0, 0));
}
}

public static ValidationResult ValidateSpecialCharacters(string zip)
{
var regexItem = new Regex("^[a-zA-Z0-9 ]*$");

return regexItem.IsMatch(zip)
? ValidationResult.Success
: new ValidationResult("Cannot have Special characters");
}


1603190.gif

I dont want Property to be Constant

Continue reading...
 
Back
Top