コード例 #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);
     }
 }