/// <summary> /// Adds a new rule to the collection. /// </summary> /// <param name="isValid"></param> /// <param name="errorDelegate"></param> /// <param name="propertyNames">Names of the properties it affects.</param> public void Add(IsValidDelegateDefinition isValid, CustomErrorDelegateDefinition errorDelegate, params string[] propertyNames) { if (propertyNames == null) { throw new ArgumentNullException("propertyNames"); } foreach (string propertyName in propertyNames) { this.Add(isValid, errorDelegate, propertyName); } }
/// <summary> /// Adds a new rule to the collection. /// </summary> /// <param name="isValid"></param> /// <param name="errorDelegate"></param> /// <param name="propertyName"></param> public void Add(IsValidDelegateDefinition isValid, CustomErrorDelegateDefinition errorDelegate, string propertyName) { this.Add(new DelegateValidationRule(isValid, propertyName, errorDelegate)); }
/// <summary> /// Constructor for DelegateValidationRule. /// </summary> /// <param name="isValid">Validation delegate.</param> /// <param name="propertyName">Target property.</param> /// <param name="errorDelegate">Function creating the error message.</param> public DelegateValidationRule(IsValidDelegateDefinition isValid, string propertyName, CustomErrorDelegateDefinition errorDelegate) : base(isValid, "", propertyName) { ErrorDelegate = errorDelegate; }
/// <summary> /// Add a new rule to the collection. /// </summary> /// <param name="isValid">Rule checking function.</param> /// <param name="errorMessage"> Error if rule checking function returns false.</param> /// <param name="propertyName">Name of the property it affects.</param> public void Add(IsValidDelegateDefinition isValid, string errorMessage, string propertyName) { this.Add(new ValidationRule(isValid, errorMessage, propertyName)); }
/// <summary> /// </summary> /// <param name="isValid">Property IsValid</param> /// <param name="errorMessage">Property ErrorMessage-</param> /// <param name="propertyName">Property PropertyName</param> public ValidationRule(IsValidDelegateDefinition isValid, string errorMessage, string propertyName) { ErrorMessage = errorMessage; PropertyName = propertyName; IsValid = isValid; }