/// <summary>
        /// Allows you to specify a custom assertion that validates the <see cref="License"/>.
        /// </summary>
        /// <param name="validationChain">The current <see cref="IStartValidationChain"/>.</param>
        /// <param name="predicate">The predicate to determine of the <see cref="License"/> is valid.</param>
        /// <param name="failure">The <see cref="IValidationFailure"/> will be returned to the application when the <see cref="ILicenseValidator"/> fails.</param>
        /// <returns>An instance of <see cref="IStartValidationChain"/>.</returns>
        public static IValidationChain AssertThat(this IStartValidationChain validationChain, Predicate <License> predicate, IValidationFailure failure)
        {
            var validationChainBuilder = (validationChain as ValidationChainBuilder);
            var validator = validationChainBuilder.StartValidatorChain();

            validator.Validate      = predicate;
            validator.FailureResult = failure;

            return(validationChainBuilder);
        }
예제 #2
0
 public void AddError(IValidationFailure failure)
 {
     this.Errors.Add(failure);
 }
예제 #3
0
 public ValidationFailure(IValidationFailure failure)
     : base(failure.ToString())
 {
     this.Failure = failure;
 }
        /// <summary>
        /// Allows you to specify a custom assertion that validates the <see cref="License"/>.
        /// </summary>
        /// <param name="validationChain">The current <see cref="IStartValidationChain"/>.</param>
        /// <param name="predicate">The predicate to determine of the <see cref="License"/> is valid.</param>
        /// <param name="failure">The <see cref="IValidationFailure"/> will be returned to the application when the <see cref="ILicenseValidator"/> fails.</param>
        /// <returns>An instance of <see cref="IStartValidationChain"/>.</returns>
        public static IValidationChain AssertThat(this IStartValidationChain validationChain, Predicate<License> predicate, IValidationFailure failure)
        {
            var validationChainBuilder = (validationChain as ValidationChainBuilder);
            var validator = validationChainBuilder.StartValidatorChain();

            validator.Validate = predicate;
            validator.FailureResult = failure;

            return validationChainBuilder;
        }
예제 #5
0
 public ValidationFailure(IValidationFailure failure, string internalMessage)
     : base(failure.ToString(), internalMessage)
 {
     this.Failure = failure;
 }