Пример #1
0
 public static ValidationNotification ToNotification(this IEnumerable<ValidationResult> validationResults)
 {
     var notification = new ValidationNotification()
     {
         Errors = validationResults.ToList()
     };
     return notification;
 }
Пример #2
0
 /// <summary>
 /// Validates an instance of T against the rules defined in the specification and a SpecificationContainer.
 /// </summary>
 /// <remarks>
 /// This is useful when using a specification leverages other specifications for referenced types.  The referenced
 /// types will be validated against their specifications contained in the SpecificationContainer.
 /// </remarks>
 /// <param name="instance">Instance of T to validate.</param>
 /// <param name="specificationContainer">The <see cref="SpecificationContainer"/></param>
 /// <returns><see cref="ValidationNotification"/></returns>
 public ValidationNotification Validate(T instance, SpecificationContainer specificationContainer)
 {
     lock (this)
     {
         var notification = new ValidationNotification();
         PropertyValidators.Select(x => x.Validate(instance, specificationContainer, notification));
         return(notification);
     }
 }
Пример #3
0
 public bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification)
 {
     lock (this)
     {
         foreach (var validator in PropertyValidators)
         {
             validator.Validate(instance, specificationContainer, notification);
         }
         return notification.IsValid;
     }
 }
Пример #4
0
 /// <summary>
 /// Validates an instance of T against the rules defined in the specification.
 /// </summary>
 /// <param name="instance">Instance of T to validate.</param>
 /// <returns><see cref="ValidationNotification"/></returns>
 public ValidationNotification Validate(T instance)
 {
     lock (this)
     {
         var notification = new ValidationNotification();
         foreach (var propertyValidator in PropertyValidators)
         {
             propertyValidator.Validate(instance, null, notification);
         }
         return(notification);
     }
 }
Пример #5
0
 public ValidationException(string message, ValidationNotification vn)
 {
     _notification = vn;
     _message = message;
 }
Пример #6
0
 public ValidationException(ValidationNotification vn)
 {
     _notification = vn;
 }
Пример #7
0
 public abstract bool Validate(object instance, RuleValidatorContext parentRuleContexts, SpecificationContainer specificationContainer, ValidationNotification notification);
Пример #8
0
 public abstract bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification);
Пример #9
0
 public ValidationException(string message, ValidationNotification vn)
 {
     _notification = vn;
     _message      = message;
 }
Пример #10
0
 public ValidationException(ValidationNotification vn)
 {
     _notification = vn;
 }
Пример #11
0
 public abstract bool Validate(object instance, RuleValidatorContext parentRuleContexts, SpecificationContainer specificationContainer, ValidationNotification notification);
Пример #12
0
 public abstract bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification);
Пример #13
0
 public bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification)
 {
     lock (this)
     {
         foreach (var validator in PropertyValidators)
         {
             validator.Validate(instance, specificationContainer, notification);
         }
         return(notification.IsValid);
     }
 }