Exemplo n.º 1
0
        /// <summary>
        /// Perform validation.
        /// </summary>
        /// <param name="ruleSetName">Name of rule set where want perform validation.</param>
        /// <returns>Return validation result set.</returns>
        protected virtual ValidationResults Validate(string ruleSetName)
        {
            var results = new ValidationResults();

            results.AddAllResults(ValidationFactory.CreateValidator(GetTypeUnproxied()).Validate(this));

            if (!String.IsNullOrEmpty(ruleSetName))
            {
                results.AddAllResults(ValidationFactory.CreateValidator(GetTypeUnproxied(), ruleSetName).Validate(this));
            }

            return(results);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Obtient une concaténation des messages d'erreur pour le nom du champ spécifié.
        /// </summary>
        public virtual string this[string columnName]
        {
            get
            {
                // L'objet n'a pas encore été validé
                if (_validationResults == null)
                {
                    return(string.Empty);
                }

                ValidationResults filteredResults = new ValidationResults();

                filteredResults.AddAllResults(_validationResults.Where(vr => vr.Key == columnName));

                if (!filteredResults.IsValid)
                {
                    //On renvoie la concaténation de toutes les erreurs sur la propriété "columnName"
                    IEnumerable <string> messages = filteredResults
                                                    .Flatten(vr => vr.NestedValidationResults)
                                                    .Where(vr => vr.NestedValidationResults == null || !vr.NestedValidationResults.Any())//on prend seulement les feuilles de l'arbre
                                                    .Select(vr => vr.Message);

                    return(string.Join("|", messages));
                }

                return(string.Empty);
            }
        }
        public void CheckLink(ValidationResults results) {
            var validator = ValidationFactory.CreateValidator<ChangesetLink>();
            var linkResults = validator.Validate(Link);

            if(!linkResults.IsValid) {
                results.AddAllResults(linkResults);
            }
        }
            protected override void DoValidate(decimal?objectToValidate, object currentTarget, string key, ValidationResults validationResults)
            {
                if (objectToValidate == null)
                {
                    return;
                }

                validationResults.AddAllResults(_innerValidator.Validate(objectToValidate.Value));
            }
Exemplo n.º 5
0
        public void CheckLink(ValidationResults results)
        {
            var validator   = ValidationFactory.CreateValidator <ChangesetLink>();
            var linkResults = validator.Validate(Link);

            if (!linkResults.IsValid)
            {
                results.AddAllResults(linkResults);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Validates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <exception cref="ps.dmv.common.Exceptions.BusinessValidationException"></exception>
        protected void Validate(T entity)
        {
            IValidationProvider validator = ServiceLocator.Instance.Resolve <IValidationProvider>();

            ValidationResults validationResults = new ValidationResults();

            ValidationResults validationResultsEntity = validator.Validate(entity);

            validationResults.AddAllResults(validationResultsEntity);

            ValidationResults validationResultsSpecial = ValidateSpecial(entity);

            validationResults.AddAllResults(validationResultsSpecial);

            if (!validationResults.IsValid)
            {
                throw new BusinessValidationException(validationResults);
            }
        }
        public static ValidationResults ValidateMany <T>(this IEnumerable <T> i) where T : CoreData
        {
            ValidationResults vr = new ValidationResults();

            foreach (var item in i)
            {
                vr.AddAllResults(item.Validate());
            }
            return(vr);
        }
        public void CheckProjects(ValidationResults results) {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(TestPublishProjectMapping),
                string.Empty);

            foreach (TestPublishProjectMapping project in Projects) {
                var projectResults = validator.Validate(project);
                
                if(!projectResults.IsValid) {
                    results.AddAllResults(projectResults);
                }
            }
        }
        public void CheckPriorityMappings(ValidationResults results)
        {
            var validator = ValidationFactory.CreateValidator <JiraPriorityMapping>();

            foreach (var mapping in PriorityMappings)
            {
                var mappingValidationResults = validator.Validate(mapping);

                if (!mappingValidationResults.IsValid)
                {
                    results.AddAllResults(mappingValidationResults);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Does the validate.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        /// <param name="currentTarget">The current target.</param>
        /// <param name="key">The key.</param>
        /// <param name="validationResults">The validation results.</param>
        protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            Validator validator = new ValidationIntegrationHelper(this).GetValidator();

            if (validator != null)
            {
                ValidationResults results = validator.Validate(this);

                if (!results.IsValid)
                {
                    validationResults.AddAllResults(results);
                }
            }
        }
        public void CheckProjects(ValidationResults results)
        {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(TestPublishProjectMapping),
                                                                            string.Empty);

            foreach (TestPublishProjectMapping project in Projects)
            {
                var projectResults = validator.Validate(project);

                if (!projectResults.IsValid)
                {
                    results.AddAllResults(projectResults);
                }
            }
        }
Exemplo n.º 12
0
        public void HeaderValidation(ValidationResults results)
        {
            string msg;

            if (DocumentURISpecified)
            {
                var documentURIValidator = ValidationFactory.CreateValidator <DocumentURI>();
                results.AddAllResults(documentURIValidator.Validate(this.DocumentURI));
            }

            if (!this.DocumentTypeURISpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Sections.R0033, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }

            if (!this.ElectronicServiceProviderBasicDataSpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Sections.R0021, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }

            if (!this.ElectronicServiceApplicantSpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Sections.R0087, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }

            if (!this.ElectronicServiceApplicantContactDataSpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Sections.R1164, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }

            if (!this.SendApplicationWithReceiptAcknowledgedMessageSpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Fields._0008_000198, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }

            if (!this.ApplicationTypeSpecified)
            {
                msg = string.Format(Resources.Terms._0006_000015, Resources.Fields.R1295, Resources.Sections.R1234);
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult(msg, this, "", "0006-000015", null));
            }
        }
Exemplo n.º 13
0
        public virtual ValidationResults Validate(bool validateRelatedObjects)
        {
            var results = new ValidationResults();

            foreach (var property in this.GetType().GetProperties())
            {
                // related properties
                if (property.PropertyType.GetInterface(typeof(IEnumerable).FullName) != null && property.PropertyType.IsGenericType && validateRelatedObjects)
                {
                    // collection type
                    if (!validateRelatedObjects)
                    {
                        continue;
                    }
                    var collection = property.GetValue(this, null) as IEnumerable;
                    if (collection != null)
                    {
                        foreach (var item in collection)
                        {
                            // only run validation if the item is an entity itself
                            if (item is IValidatable)
                            {
                                results.AddAllResults((item as IValidatable).Validate(false));
                            }
                        }
                    }
                }
                else   // simple properties on the underlying Model
                {
                    // simple type property
                    var entityProperty = Model.GetType().GetProperty(property.Name);
                    if (entityProperty == null)
                    {
                        continue;
                    }

                    var validator = GetPropertyValidator(this, entityProperty);
                    if (validator != null)
                    {
                        validator.Validate(this.Model, results);
                    }
                }
            }
            return(results);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Validates by applying the validation rules for the target type specified for the receiver.
 /// </summary>
 /// <param name="objectToValidate">The object to validate.</param>
 /// <param name="currentTarget">The object on the behalf of which the validation is performed.</param>
 /// <param name="key">The key that identifies the source of <paramref name="objectToValidate"/>.</param>
 /// <param name="validationResults">The validation results to which the outcome of the validation should be stored.</param>
 /// <remarks>
 /// If <paramref name="objectToValidate"/> is <see langword="null"/> validation is ignored.
 /// <para/>
 /// A referece to an instance of a type not compatible with the configured target type
 /// causes a validation failure.
 /// </remarks>
 protected internal override void DoValidate(object objectToValidate,
                                             object currentTarget,
                                             string key,
                                             ValidationResults validationResults)
 {
     if (objectToValidate != null)
     {
         if (this.targetType.IsAssignableFrom(objectToValidate.GetType()))
         {
             validationResults.AddAllResults(
                 ValidationFactory.CreateValidator(objectToValidate.GetType()).Validate(objectToValidate));
         }
         else
         {
             // unlikely
             this.LogValidationResult(validationResults, Resources.ObjectValidatorInvalidTargetType, currentTarget, key);
         }
     }
 }
        public void ActIdentifierValidation(ValidationResults results)
        {
            ValidationResults valResults = null;

            Microsoft.Practices.EnterpriseLibrary.Validation.Validator validator = null;

            if (StateIdentifier != null)
            {
                validator = ValidationFactory.CreateValidator <StatePropertyActIdentifier>();
            }
            else if (MunicipalIdentifier != null)
            {
                validator = ValidationFactory.CreateValidator <MunicipalPropertyActIdentifier>();
            }

            if (validator != null)
            {
                valResults = validator.Validate(Item);
                results.AddAllResults(valResults);
            }
        }
        public void LandPropertyOldIdentifierValidation(ValidationResults results)
        {
            string            msg;
            ValidationResults valResults = null;

            Microsoft.Practices.EnterpriseLibrary.Validation.Validator validator = null;

            if (UrbanIdentifier != null)
            {
                validator = ValidationFactory.CreateValidator <UrbanLandPropertyOldIdentifier>();
            }
            else if (FarmlandIdentifier != null)
            {
                validator = ValidationFactory.CreateValidator <FarmlandAndForestLandPropertyOldIdentifier>();
            }

            if (validator != null)
            {
                valResults = validator.Validate(Item);
                results.AddAllResults(valResults);
            }
        }
Exemplo n.º 17
0
        public void CanAddValidationResultsFromCollection()
        {
            ValidationResults validationResults = new ValidationResults();

            validationResults.AddResult(new ValidationResult("existing 1", null, null, null, null));
            validationResults.AddResult(new ValidationResult("existing 2", null, null, null, null));
            ValidationResult[] newValidationResults = new ValidationResult[] {
                new ValidationResult("new 1", null, null, null, null),
                new ValidationResult("new 2", null, null, null, null),
                new ValidationResult("new 3", null, null, null, null)
            };

            validationResults.AddAllResults(newValidationResults);

            IDictionary <string, ValidationResult> resultsMapping = ValidationTestHelper.GetResultsMapping(validationResults);

            Assert.AreEqual(5, resultsMapping.Count);
            Assert.IsTrue(resultsMapping.ContainsKey("existing 1"));
            Assert.IsTrue(resultsMapping.ContainsKey("existing 2"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 1"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 2"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 3"));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Does the validate.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        /// <param name="currentTarget">The current target.</param>
        /// <param name="key">The key.</param>
        /// <param name="validationResults">The validation results.</param>
		protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults validationResults)
		{
			Validator validator = new ValidationIntegrationHelper(this).GetValidator();

			if (validator != null)
			{
				ValidationResults results = validator.Validate(this);

				if (!results.IsValid)
				{
					validationResults.AddAllResults(results);
				}
			}
		}
Exemplo n.º 19
0
 public void DoValidateSave(ValidationResults results)
 {
     results.AddAllResults(
             Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Airfare>(this.FlightArrangements, "Save"));
      results.AddAllResults(
              Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Ground>(this.GroundArrangements, "Save"));
      results.AddAllResults(
              Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Lodging>(this.LodgingArrangements, "Save"));
 }
Exemplo n.º 20
0
        protected override void DoValidate(BankTransaction objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            if (objectToValidate.Contact == null)
            {
                validationResults.AddResult(new ValidationResult("The document has no Contact", currentTarget, key, "Contact", this));
            }

            if (objectToValidate.LineItems == null || !objectToValidate.LineItems.Any())
            {
                validationResults.AddResult(new ValidationResult("The document has no LineItems", currentTarget, key, "LineItems", this));
            }
            else
            {
                ValidationResults vr = new ValidationResults();
                foreach (var item in objectToValidate.LineItems)
                {
                    var valResults = lineItemValidator.Validate(item).AsEnumerable();
                    if (objectToValidate.Type.IsOverpayment())
                    {
                        valResults = valResults.Where(a => a.Tag != LineItemValidator.AccountCode);
                    }

                    vr.AddAllResults(valResults);

                    bool?isValidTax = item.IsValidTax();
                    if (isValidTax.HasValue && !isValidTax.Value)
                    {
                        var msg = string.Format("Invalid Tax Amount ({0} expected: {1})", item.TaxAmount, item.CalculateTaxAmount());
                        vr.AddResult(new ValidationResult(msg, currentTarget, key, "TaxAmount", this));
                    }
                }
                if (vr.Any())
                {
                    validationResults.AddResult(new ValidationResult("Invalid LineItems", currentTarget, key, "LineItems", this, vr));
                }

                if (objectToValidate.LineItems.GetLineItemTotal() <= 0)
                {
                    validationResults.AddResult(new ValidationResult("The LineItems total must be greater than 0.", currentTarget, key, "LineItems", this));
                }
            }

            if (objectToValidate.Total.HasValue)
            {
                if (objectToValidate.Total.Value != objectToValidate.LineItems.Sum(a => a.GetLineItemTotal()))
                {
                    validationResults.AddResult(new ValidationResult("The document total does not equal the sum of the lines.", currentTarget, key, "Total", this));
                }
                if (objectToValidate.Total.Value <= 0)
                {
                    validationResults.AddResult(new ValidationResult("The document total must be greater than 0.", currentTarget, key, "Total", this));
                }
            }

            if (objectToValidate.SubTotal.HasValue)
            {
                if (objectToValidate.SubTotal.Value != objectToValidate.LineItems.GetLineItemSubTotal())
                {
                    validationResults.AddResult(new ValidationResult("The document subtotal does not equal the sum of the lines.", currentTarget, key, "SubTotal", this));
                }
                if (objectToValidate.SubTotal.Value <= 0)
                {
                    validationResults.AddResult(new ValidationResult("The document subtotal must be greater than 0.", currentTarget, key, "SubTotal", this));
                }
            }

            if (objectToValidate.TotalTax.HasValue)
            {
                if (objectToValidate.TotalTax.Value != objectToValidate.LineItems.Sum(a => a.TaxAmount))
                {
                    validationResults.AddResult(
                        new ValidationResult("The document totaltax does not equal the sum of the lines.", currentTarget,
                                             key, "TotalTax", this));
                }
                if (objectToValidate.TotalTax.Value < 0)
                {
                    validationResults.AddResult(
                        new ValidationResult("The document totaltax must be greater than or equal to 0.", currentTarget,
                                             key, "TotalTax", this));
                }
            }
        }
Exemplo n.º 21
0
 public void DoValidateSubmit(ValidationResults results)
 {
     if (!this.HasFlightArrangements && !this.HasGroundArrangements && !this.HasLodgingArrangements)
         results.AddResult(new ValidationResult("At least one travel arrangement is required.",
             typeof(TravelEstimate), "", "travel arrangement", null));
     else
     {
         if (this.HasFlightArrangements)
         {
             results.AddAllResults(
                 Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Airfare>(this.FlightArrangements, "Submit"));
         }
         if (this.HasGroundArrangements)
         {
             results.AddAllResults(
                  Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Ground>(this.GroundArrangements, "Submit"));
         }
         if (this.HasLodgingArrangements)
         {
             results.AddAllResults(
                  Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<Lodging>(this.LodgingArrangements, "Submit"));
         }
     }
 }
        public void CanAddValidationResultsFromCollection()
        {
            ValidationResults validationResults = new ValidationResults();
            validationResults.AddResult(new ValidationResult("existing 1", null, null, null, null));
            validationResults.AddResult(new ValidationResult("existing 2", null, null, null, null));
            ValidationResult[] newValidationResults = new ValidationResult[]
                {
                    new ValidationResult("new 1", null, null, null, null),
                    new ValidationResult("new 2", null, null, null, null),
                    new ValidationResult("new 3", null, null, null, null)
                };

            validationResults.AddAllResults(newValidationResults);

            IDictionary<string, ValidationResult> resultsMapping = ValidationTestHelper.GetResultsMapping(validationResults);
            Assert.AreEqual(5, resultsMapping.Count);
            Assert.IsTrue(resultsMapping.ContainsKey("existing 1"));
            Assert.IsTrue(resultsMapping.ContainsKey("existing 2"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 1"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 2"));
            Assert.IsTrue(resultsMapping.ContainsKey("new 3"));
        }
        public void CheckPriorityMappings(ValidationResults results) {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(QCPriorityMapping), string.Empty);

            foreach(QCPriorityMapping mapping in PriorityMappings) {
                results.AddAllResults(validator.Validate(mapping));                
            }
        }
        public void CheckPriorityMappings(ValidationResults results) {
            var validator = ValidationFactory.CreateValidator<ClearQuestPriorityMapping>();

            foreach(ClearQuestPriorityMapping mapping in PriorityMappings) {
                var mappingValidationResults = validator.Validate(mapping);

                if(!mappingValidationResults.IsValid) {
                    results.AddAllResults(mappingValidationResults);
                }
            }
        }
        public void CheckDefectFilters(ValidationResults results) {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(QCDefectFilter), string.Empty);

            foreach(QCDefectFilter filter in DefectFilters) {
                results.AddAllResults(validator.Validate(filter));
            }
        }
Exemplo n.º 26
0
        public void DataValidation(ProjectAllocationFramework.Statues.ProgressChangedEventHandler OnProgress, List <WorkerEntity> entityList)
        {
            if (entityList == null || entityList.Count == 0)
            {
                return;
            }

            List <WorkerEntity> userDBList = GetDataFromDB(OnProgress);
            var WorkerCodeDBList           = from item in userDBList
                                             select item.WorkerCode;
            ListRangeValidator <string> WorkerCodeListRangeValidator = new ListRangeValidator <string>(WorkerCodeDBList.ToList <string>(), true, ProjectAllocationResource.Message.Worker_WorkerCode_Exists);


            var WorkerCodeList = from item in entityList
                                 select item.WorkerCode;
            UniqueValidator <string> UniqueValidator = new UniqueValidator <string>(WorkerCodeList.ToList <string>(), ProjectAllocationResource.Message.Worker_WorkerCode_Unique);

            ValidatorFactory         valFactory      = EnterpriseLibraryContainer.Current.GetInstance <ValidatorFactory>();
            Validator <WorkerEntity> entityValidator = valFactory.CreateValidator <WorkerEntity>();
            int           i       = 1;
            bool          noError = true;
            int           count   = entityList.Count();
            StringBuilder builder = new StringBuilder();

            foreach (WorkerEntity entity in entityList)
            {
                ValidationResults results = entityValidator.Validate(entity);

                if (!entity.ReadOnly)
                {
                    ValidationResults userExistCheckResults = WorkerCodeListRangeValidator.Validate(entity.WorkerCode);
                    results.AddAllResults(userExistCheckResults);
                }

                ValidationResults uniqueCheckResult = UniqueValidator.Validate(entity.WorkerCode);
                results.AddAllResults(uniqueCheckResult);

                bool isValid = results.IsValid;

                noError &= isValid;

                if (!isValid)
                {
                    builder.AppendLine(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            ProjectAllocationResource.Message.Common_Row_Error,
                            entity.Row));

                    foreach (ValidationResult result in results)
                    {
                        builder.AppendLine(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                ProjectAllocationResource.Message.Common_Field_Error,
                                result.Message));
                    }
                }
                if (OnProgress != null)
                {
                    string InfomationMessage = string.Format(ProjectAllocationResource.Message.Common_Master_Validate_Info, i);
                    int    Percentage        = (int)(i * Constant.ProgressBarMaximum / count);
                    ProjectAllocationFramework.Statues.ProgressChangedEventArgs args = new ProjectAllocationFramework.Statues.ProgressChangedEventArgs(InfomationMessage, Percentage, null);
                    OnProgress(this, args);
                }

                i++;
            }

            if (!noError)
            {
                throw new ProjectAllocationFramework.RuntimeException("Validation Error", builder.ToString());
            }
        }
        public void DataValidation(BudgetProgressChangedEventHandler OnProgress, List <CurrencyEntity> entityList)
        {
            if (entityList == null || entityList.Count == 0)
            {
                return;
            }

            //List<CategoryEntity> categoryDBList = GetAllCategoryDataFromDB(OnProgress);
            //var categoryCodeDBList = from item in categoryDBList
            //          select item.CategoryCode;
            //ListRangeValidator<string> categoryCodelistRangeValidator = new ListRangeValidator<string>(categoryCodeDBList.ToList<string>(), BudgetResource.Message.Currency_CategoryCode_NoExist);

            List <CurrencyEntity> currencyDBList = GetDataFromDB(OnProgress);
            var currencyCodeDBList = from item in currencyDBList
                                     select item.CurrencyCode;
            ListRangeValidator <string> currencyCodeListRangeValidator = new ListRangeValidator <string>(currencyCodeDBList.ToList <string>(), true, BudgetResource.Message.Currency_CurrencyCode_Exists);


            var currencyCodeList = from item in entityList
                                   select item.CurrencyCode;
            UniqueValidator <string> UniqueValidator = new UniqueValidator <string>(currencyCodeList.ToList <string>(), BudgetResource.Message.Currency_CurrencyCode_Unique);

            ValidatorFactory           valFactory      = EnterpriseLibraryContainer.Current.GetInstance <ValidatorFactory>();
            Validator <CurrencyEntity> entityValidator = valFactory.CreateValidator <CurrencyEntity>();
            int           i       = 1;
            bool          noError = true;
            int           count   = entityList.Count();
            StringBuilder builder = new StringBuilder();

            foreach (CurrencyEntity entity in entityList)
            {
                ValidationResults results = entityValidator.Validate(entity);

                //ValidationResults categoryExistCheckResults = categoryCodelistRangeValidator.Validate(entity.CategoryCode);
                //results.AddAllResults(categoryExistCheckResults);

                if (!entity.ReadOnly)
                {
                    ValidationResults currencyExistCheckResults = currencyCodeListRangeValidator.Validate(entity.CurrencyCode);
                    results.AddAllResults(currencyExistCheckResults);
                }

                ValidationResults uniqueCheckResult = UniqueValidator.Validate(entity.CurrencyCode);
                results.AddAllResults(uniqueCheckResult);

                bool isValid = results.IsValid;

                noError &= isValid;

                if (!isValid)
                {
                    builder.AppendLine(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            BudgetResource.Message.Common_Row_Error,
                            entity.Row));

                    foreach (ValidationResult result in results)
                    {
                        builder.AppendLine(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                BudgetResource.Message.Common_Field_Error,
                                result.Message));
                    }
                }
                if (OnProgress != null)
                {
                    string InfomationMessage            = string.Format("you are validating No. {0} data", i);
                    int    Percentage                   = (int)(i * BudgetConstant.ProgressBarMaximum / count);
                    BudgetProgressChangedEventArgs args = new BudgetProgressChangedEventArgs(InfomationMessage, Percentage, null);
                    OnProgress(this, args);
                }

                i++;
            }

            if (!noError)
            {
                throw new BudgetRuntimeException("Validation Error", builder.ToString());
            }
        }
        public void DoValidateEstimates(ValidationResults results)
        {
            if (this.HasTraining)
            {
                results.AddAllResults(
                    Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<TrainingEstimate>(this.Training, "Estimates"));
                if (!this.Training.StartingDate.IsBetween(this.EventStart, this.EventEnd, true))
                {
                    results.AddResult(new ValidationResult(
                           "The start date is not valid.",
                           typeof(TrainingEstimate), "", "training start date", null));
                }
                if (!this.Training.EndingDate.IsBetween(this.EventStart, this.EventEnd, true))
                {
                    results.AddResult(new ValidationResult(
                           "The end date is not valid",
                           typeof(TrainingEstimate), "", "training start date", null));
                }
            }
            if (this.HasTravel)
            {
                results.AddAllResults(
                    Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<TravelEstimate>(this.Travel, "Estimates"));
            }

            if (this.MiscealleanousCostsComments.Length > 0 && this.MisceallaneousCosts <= 0M)
            {
                results.AddResult(new ValidationResult("General comments estimated cost is required.",
                        typeof(TravelAndTrainingRequest),
                        "", "", null));
            }
            else if (this.MisceallaneousCosts != 0M &&
                this.MiscealleanousCostsComments.Length == 0)
            {
                results.AddResult(new ValidationResult("General comments are required.",
                        typeof(TravelAndTrainingRequest),
                        "", "", null));
            }
        }
        public void CheckProjects(ValidationResults results) {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(QCProject), string.Empty);

            foreach(QCProject project in Projects) {
                results.AddAllResults(validator.Validate(project));
            }
        }
        public void CheckMandatoryFields(ValidationResults results) {
            var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(ClearQuestField), string.Empty);

            foreach(ClearQuestField field in MandatoryFields) {
                var fieldResults = validator.Validate(field);
                
                if(!fieldResults.IsValid) {
                    results.AddAllResults(fieldResults);
                }
            }
        }
 public void CheckConnection(ValidationResults results) {
     var validator = ValidationFactory.CreateValidatorFromAttributes(typeof(QCConnection), string.Empty);
     var defectFilterResults = validator.Validate(Connection);
     results.AddAllResults(defectFilterResults);
 }
 public void DoValidateSave(ValidationResults results)
 {
     results.AddAllResults(
         Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<TrainingEstimate>(this.Training, "Save"));
     results.AddAllResults(
         Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate<TravelEstimate>(this.Travel, "Save"));
 }
        public void CheckProjectMappings(ValidationResults results)
        {
            var validator = ValidationFactory.CreateValidator<JiraProjectMapping>();

            foreach (var mapping in ProjectMappings)
            {
                var mappingValidationResults = validator.Validate(mapping);

                if (!mappingValidationResults.IsValid)
                {
                    results.AddAllResults(mappingValidationResults);
                }
            }
        }