Beispiel #1
0
 protected override LocalizedString CustomErrorMessage(string value, PropertyDefinition propertyDefinition)
 {
     if (this.ShowAsValid)
     {
         return(DataStrings.ConstraintViolationStringContainsInvalidCharacters2(this.characterString, value));
     }
     return(DataStrings.ConstraintViolationStringContainsInvalidCharacters(this.characterString, value));
 }
		public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
		{
			string text = (string)value;
			int num = -1;
			if (!string.IsNullOrEmpty(text) && ADObjectNameHelper.CheckIsUnicodeStringWellFormed(text, out num))
			{
				if (ADObjectNameHelper.ReservedADNameStringRegex.IsMatch(text))
				{
					return null;
				}
				return base.Validate(value, propertyDefinition, propertyBag);
			}
			else
			{
				if (num == -1)
				{
					return new PropertyConstraintViolationError(DataStrings.ConstraintViolationStringLengthIsEmpty, propertyDefinition, value, this);
				}
				return new PropertyConstraintViolationError(DataStrings.ConstraintViolationStringContainsInvalidCharacters(text.Substring(num, 1), text), propertyDefinition, value, this);
			}
		}