public static ValidationNotification ToNotification(this IEnumerable<ValidationResult> validationResults) { var notification = new ValidationNotification() { Errors = validationResults.ToList() }; return notification; }
/// <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); } }
public bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification) { lock (this) { foreach (var validator in PropertyValidators) { validator.Validate(instance, specificationContainer, notification); } return notification.IsValid; } }
/// <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); } }
public ValidationException(string message, ValidationNotification vn) { _notification = vn; _message = message; }
public ValidationException(ValidationNotification vn) { _notification = vn; }
public abstract bool Validate(object instance, RuleValidatorContext parentRuleContexts, SpecificationContainer specificationContainer, ValidationNotification notification);
public abstract bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification);
public bool Validate(object instance, SpecificationContainer specificationContainer, ValidationNotification notification) { lock (this) { foreach (var validator in PropertyValidators) { validator.Validate(instance, specificationContainer, notification); } return(notification.IsValid); } }