public void TestEntLibValidation() { var valFactory = ServiceFactory.GetInstance <ValidatorFactory>(); var myCustomer = new Customer(); myCustomer.CustomerId = -2; myCustomer.CustomerName = "This is testname for current product"; Validator <Customer> customerValidator = valFactory.CreateValidator <Customer>(); ValidationResults results = customerValidator.Validate(myCustomer); Console.WriteLine(results.ToString()); // Check if the ValidationResults detected any validation errors. if (results.IsValid) { Console.WriteLine("There were no validation errors."); } else { Console.WriteLine("The following {0} validation errors were detected:", results.Count); // Iterate through the collection of validation results. foreach (ValidationResult item in results) { // Show the target member name and current value. Console.WriteLine( "Target:'{0}' Key:'{1}' Tag:'{2}' Message:'{3}'", item.Target, item.Key, item.Tag, item.Message); } } Assert.False(results.IsValid); }
public ValidationResultsDialog(Window owner, string title, ValidationResults vr) { InitializeComponent(); this.Owner = owner; this.Title = title; ValidationResultsTextBox.Text = vr.ToString(); }
/// <summary> /// 验证当前数类型 /// </summary> protected virtual void Validate() { if (this._NeedValidation) { ValidationResults validationResults = new ValidationResults(); DoValidate(validationResults); ExceptionHelper.TrueThrow(validationResults.ResultCount > 0, validationResults.ToString()); } }
/// <summary> /// 验证当前数类型 /// </summary> protected virtual void Validate() { #region “验证” if (this._NeedValidation) { ValidationResults validationResults = new ValidationResults(); DoValidate(validationResults); ExceptionHelper.TrueThrow(validationResults.ResultCount > 0, validationResults.ToString()); } CheckStatus(); #endregion }
/// <summary> /// 验证当前数类型 /// </summary> protected virtual void Validate() { #region “验证” if (this._NeedValidation) { ValidationResults validationResults = new ValidationResults(); DoValidate(validationResults); if (validationResults.ResultCount > 0) { throw new AUObjectValidationException(validationResults.ToString(), this.Data); } } CheckStatus(); #endregion }
public void PropertyValueValidatorTest() { PropertyGroupConfigurationElementCollection groups = PropertyGroupSettings.GetConfig().Groups; foreach (PropertyGroupConfigurationElement group in groups) { PropertyDefineCollection propertiesDefinitions = new PropertyDefineCollection(); propertiesDefinitions.LoadPropertiesFromConfiguration(group); PropertyValueCollection properties = new PropertyValueCollection(); properties.AppendFromPropertyDefineCollection(propertiesDefinitions); ValidationResults results = properties.Validate(); Console.WriteLine(results.ToString("\r\n")); } }
protected override void Validate() { if (this.NeedValidation == true) { DESchemaPropertyValidatorContext context = DESchemaPropertyValidatorContext.Current; try { context.Target = this.Data; context.Container = this._Container; ValidationResults validationResult = new ValidationResults(); if (this.Data.Status == SchemaObjectStatus.Normal) { validationResult = this.Data.Validate(); } //haoyk 2014-2-8 if (this.SaveMemberData && this.Members.Any()) { this.Members.Where(p => p.Status == SchemaObjectStatus.Normal).ForEach(p => { ValidationResults results = p.Validate(); if (results != null && results.Any()) { results.ForEach(validationResult.AddResult); } }); } ExceptionHelper.TrueThrow(validationResult.ResultCount > 0, validationResult.ToString()); CheckStatus(); } finally { DESchemaPropertyValidatorContext.Clear(); } } }
protected virtual void Validate() { #region “验证” this._RelationExisted.TrueThrow("无法进行移动,因为对象在目标位置已经存在。"); ValidationResults validationResults = new ValidationResults(); ValidationResults relationValidationResults = this._TargetRelation.Validate(); foreach (ValidationResult result in relationValidationResults) { validationResults.AddResult(result); } ExceptionHelper.TrueThrow(validationResults.ResultCount > 0, validationResults.ToString()); if (this._NeedStatusCheck) { CheckObjectStatus(this._Object, this._TargetOrganization); } #endregion }
protected override void Validate() { if (this.NeedValidation == true) { SchemaPropertyValidatorContext context = SchemaPropertyValidatorContext.Current; try { context.Target = this.Data; context.Container = this._Container; ValidationResults validationResult = this.Data.Validate(); ExceptionHelper.TrueThrow(validationResult.ResultCount > 0, validationResult.ToString()); CheckStatus(); } finally { SchemaPropertyValidatorContext.Clear(); } } }
/// <summary> /// 验证当前数类型 /// </summary> protected virtual void Validate() { #region “验证” if (this._NeedValidation) { ValidationResults validationResults = new ValidationResults(); DoValidate(validationResults); if (validationResults.ResultCount > 0) throw new AUObjectValidationException(validationResults.ToString(), this.Data); } CheckStatus(); #endregion }
protected virtual void Validate() { #region “验证” this._RelationExisted.TrueThrow("无法进行移动,因为对象在目标位置已经存在。"); ValidationResults validationResults = new ValidationResults(); ValidationResults relationValidationResults = this._TargetRelation.Validate(); foreach (ValidationResult result in relationValidationResults) validationResults.AddResult(result); ExceptionHelper.TrueThrow(validationResults.ResultCount > 0, validationResults.ToString()); if (this._NeedStatusCheck) CheckObjectStatus(this._Object, this._TargetOrganization); #endregion }