public override IValidationResultCollection Validate() { ValidationResultCollection results = new ValidationResultCollection(ResourceManager); results.Passed = true; if (Object != null) { if (Object.Encoding != null) { int line = 0; int col = 0; if (Object.AssociatedObject != null) { line = Object.AssociatedObject.Line; col = Object.AssociatedObject.Column; } switch (Object.Encoding) { case "7BIT": case "8BIT": case "BASE64": break; case "QUOTED-PRINTABLE": Warning(results, "deprecatedEncodingError", line, col, Object.Encoding); break; default: Warning(results, "invalidEncodingError", line, col, Object.Encoding); break; } } } return results; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "emptyLine"); result.Passed = true; // Convert all variations of newlines to a simple "\n" so // we can easily detect empty lines. string simpleNewlineCalendar = iCalText.Replace("\r\n", "\n"); simpleNewlineCalendar = simpleNewlineCalendar.Replace("\r", "\n"); StringReader sr = new StringReader(simpleNewlineCalendar); string line = sr.ReadLine(); int lineNumber = 0; while (line != null) { lineNumber++; if (string.IsNullOrEmpty(line)) { Warning(result, "emptyLineError", lineNumber, 0, null, null); break; } line = sr.ReadLine(); } return result; }
/// <summary> /// 获取验证结果 /// </summary> private ValidationResultCollection GetResult( IEnumerable<ValidationResult> results ) { var result = new ValidationResultCollection(); foreach ( var each in results ) result.Add( new System.ComponentModel.DataAnnotations.ValidationResult( each.Message ) ); return result; }
private static IValidationResultCollection GetCompositeResultsPrivate(IResourceManager mgr, string rule, IValidator[] validators) { ValidationResultCollection results = new ValidationResultCollection(mgr, rule); foreach (IValidator validator in validators) results.Add(validator.Validate()); return results; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "inlineBinaryContent"); result.Passed = true; if (Calendars != null) { foreach (IICalendar calendar in Calendars) { foreach (IUniqueComponent uc in calendar.UniqueComponents) { IRecurringComponent rc = uc as IRecurringComponent; if (rc != null && rc.Attachments != null) { foreach (IAttachment a in rc.Attachments) { // Inline binary content (i.e. BASE64-encoded attachments) is not // recommended, and should only be used when absolutely necessary. if (string.Equals(a.Encoding, "BASE64", StringComparison.InvariantCultureIgnoreCase)) { Warning(result, "inlineBinaryContentError"); } } if (result.Passed != null) break; } } } } return result; }
protected virtual void HandleValidationResults(ValidationResultCollection results) { if (results.IsValid) { return; } _handler.Handle(results); }
/// <summary> /// 处理验证错误 /// </summary> /// <param name="results">验证错误集合</param> public void Handle(ValidationResultCollection results) { if (results.IsValid) { return; } throw new Warning(results.First().ErrorMessage); }
/// <summary> /// 处理验证结果 /// </summary> private void HandleValidationResults(ValidationResultCollection results) { if (results.IsValid) { return; } _handler.Handle(results); }
public void ValidResult() { ValidationResultCollection results = new ValidationResultCollection(new[] { _validResult }); Assert.True(results.IsValid); Assert.Empty(results.Errors); Assert.Empty(results.ErrorMessages); }
public void ValidationResult_ToString_WithCorrectFormat() { ValidationResultCollection collection = new ValidationResultCollection(); collection.Add(new ValidationResult("This is an error message", new string[] { "Property1", "Property2" })); collection.Add(new ValidationResult("This is an error message", new string[] { "Property1", "Property2" })); Assert.AreEqual("This is an error message (Property1, Property2)\nThis is an error message (Property1, Property2)\n", collection.ToString()); }
protected override void OnValidateObject(ValidationResultCollection results) { base.OnValidateObject(results); if (FirstName == LastName && FirstName != "") { results.Add(new ValidationResult("First and last names cannot match", new string[] { "FirstName", "LastName" })); } }
/// <summary> /// 处理验证结果 /// </summary> /// <param name="results"> /// The results. /// </param> private void HandleValidationResult(ValidationResultCollection results) { if (results.IsValid) { return; } this.validateionHandler.Handle(results); }
/// <summary> /// 处理验证错误 /// </summary> /// <param name="results"> /// 验证结果集合 /// </param> public void Handle(ValidationResultCollection results) { if (results.IsValid) { return; } throw new Exception(results.First().ErrorMessage); }
/// <summary> /// 处理验证错误 /// </summary> /// <param name="results">验证错误集合</param> public void Handle(ValidationResultCollection results) { if (results.IsValid) { return; } BingConfig.Current.ValidationHandler(results.First().ErrorMessage); //throw new Warning(results.First().ErrorMessage); }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "version"); foreach (IICalendar calendar in Calendars) { result.Add( ValidationResult.GetCompositeResults( ResourceManager, new PropertyCountValidation(ResourceManager, calendar, "VCALENDAR", "VERSION", 1, 1) ) ); if (BoolUtil.IsTrue(result.Passed)) { try { // Ensure the "VERSION" property can be parsed as a version number. Version v = new Version(calendar.Version); Version req = new Version(2, 0); if (req > v) { // Ensure the "VERSION" is at least version 2.0. Error(result, "versionGE2_0Error"); } // Ensure the VERSION property is the first property encountered on the calendar. StringReader sr = new StringReader(iCalText); string line = sr.ReadLine(); bool hasBegun = false; while (line != null) { if (hasBegun) { if (!line.StartsWith("VERSION", StringComparison.InvariantCultureIgnoreCase)) { Warning(result, "versionFirstError"); } break; } if (line.StartsWith("BEGIN:VCALENDAR", StringComparison.InvariantCultureIgnoreCase)) hasBegun = true; line = sr.ReadLine(); } } catch { Error(result, "versionNumberError"); } } } return result; }
void ValidateProperty(string propertyName) { var results = new ValidationResultCollection(); AttributeBasedValidation(propertyName, results); OnValidateProperty(propertyName, results); OnErrorsChanged(propertyName, ErrorsDictionary.SetErrors(propertyName, results)); }
/// <summary> /// 获取验证结果 /// </summary> private ValidationResultCollection GetResult(IEnumerable <ValidationResult> results) { var result = new ValidationResultCollection(); foreach (var each in results) { result.Add(new System.ComponentModel.DataAnnotations.ValidationResult(each.Message)); } return(result); }
/// <summary> /// 验证 /// </summary> /// <param name="target">验证目标</param> public ValidationResultCollection Validate( object target ) { target.CheckNull( "target" ); var result = new ValidationResultCollection(); var validationResults = new List<ValidationResult>(); var context = new ValidationContext( target, null, null ); var isValid = Validator.TryValidateObject( target, context, validationResults, true ); if ( !isValid ) result.AddResults( validationResults ); return result; }
/// <summary> /// 验证 /// </summary> /// <param name="modelState">实体状态字典</param> public virtual void Validate(ModelStateDictionary modelState) { var validationResult = new ValidationResultCollection(); AddErrors(validationResult, modelState); if (!validationResult.IsValid) { return; } }
public override IValidationResultCollection Validate() { bool started = false; bool hasDuration = false; bool hasEnd = false; bool errorAdded = false; int lineNumber = 0; ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "eventDTEndDurationConflict"); result.Passed = true; StringReader sr = new StringReader(iCalText); string line = sr.ReadLine(); while (line != null) { lineNumber++; if (!started) { if (line.StartsWith("BEGIN:VEVENT", StringComparison.InvariantCultureIgnoreCase)) started = true; } else { if (line.StartsWith("END:VEVENT", StringComparison.InvariantCultureIgnoreCase)) { started = false; hasDuration = false; hasEnd = false; errorAdded = false; } else if ( line.StartsWith("DTEND;", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("DTEND:", StringComparison.InvariantCultureIgnoreCase)) { hasEnd = true; } else if ( line.StartsWith("DURATION;", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("DURATION:", StringComparison.InvariantCultureIgnoreCase)) { hasDuration = true; } if (!errorAdded && hasEnd && hasDuration) { Error(result, "eventDTEndDurationConflictError", lineNumber, 0, null, null); errorAdded = true; } } line = sr.ReadLine(); } return result; }
protected override ValidationResultCollection OnValidate() { var results = new ValidationResultCollection(); foreach (var section in Sections) { results.AddResult(section.Validate()); } return(results); }
/// <summary> /// Handles the specified <see cref="ValidationResultCollection"/> with the specified parameters. /// </summary> /// <param name="validationResults">The <see cref="ValidationResultCollection"/> to handle.</param> /// <param name="p">The parameters to use during handling.</param> public void Handle(ValidationResultCollection validationResults, params object[] p) { TestManager.Register(TestItemType.ValidationResult, validationResults, validationResults.IsSucceeded ? TestAction.ValidationSucceeded : TestAction.ValidationFailed, validationResults.ToString()); if (!validationResults.IsSucceeded) { Console.WriteLine(validationResults.ConvertToString(Environment.NewLine)); throw new ValidationFailedException(validationResults); } }
partial void AttributeBasedValidation(string propertyName, ValidationResultCollection results) { var property = Properties.Metadata.Properties[propertyName]; if (property.CanRead) { var context = ValidationContextHelper.Create(this); context.MemberName = property.Name; Validator.TryValidateProperty(property.InvokeGet(this), context, results); } }
public void ValidationResultCollection_Test1() { using (var verify = new Verify()) { var collection = new ValidationResultCollection(); var result = collection.Add("Test", "FirstName", "LastName"); verify.AreEqual("Test", result.ErrorMessage, "Error message"); verify.AreEqual("FirstName", result.MemberNames.ToList()[0], "member 0"); verify.AreEqual("LastName", result.MemberNames.ToList()[1], "member 1"); } }
public DataReaderService(PackageReaderService packageType) : base() { if (packageType == null) { throw new ArgumentNullException(); } this._package = packageType; this.DataSourceFolder = packageType.package_source_full_path; this._result = new ValidationResultCollection(packageType.package_number, packageType.package_source_full_path); this.ConfigFieldsIni(); }
/// <summary> /// 获取验证结果 /// </summary> private ValidationResultCollection GetResult(IEnumerable <ValidationResult> results) { ValidationResultCollection _result = new ValidationResultCollection(); foreach (ValidationResult item in results) { _result.Add(new System.ComponentModel.DataAnnotations.ValidationResult(item.Message)); } return(_result); }
public void ValidationResultCollection_Test1() { using (var verify = new Verify()) { var collection = new ValidationResultCollection(); var result = collection.Add("Test", "FirstName", "LastName"); verify.AreEqual("Test", result.ErrorMessage, "Error message"); verify.AreEqual("FirstName", result.MemberNames.ToList()[0], "member 0"); verify.AreEqual("LastName", result.MemberNames.ToList()[1], "member 1"); } }
/// <summary> /// Shows exception message on the UI /// </summary> /// <param name="validationResults">Validation results.</param> /// <param name="p">Variable no of objects.</param> public void Handle(ValidationResultCollection validationResults, params object[] p) { Page page = HttpContext.Current.Handler as Page; if (page == null) return; var control = ControlHelper.Find<UserControl>(page, "ExceptionControl"); if (control != null) control.Visible = true; Label l = ControlHelper.Find<Label>(page, "lblException"); if (l != null) l.Text = validationResults.ToArray().ConvertToString("<br>"); }
void ValidateObject() { var results = new ValidationResultCollection(); OnValidateObject(results); OnErrorsChanged("", ErrorsDictionary.SetErrors(results, out var affectedProperties)); foreach (var p in affectedProperties) { OnErrorsChanged(p); } }
public static Result ToResults(this ValidationResultCollection validationResults) { if (!validationResults.IsValid) { Result failure = new Result(); foreach (string errorMessage in validationResults.ErrorMessages) { failure = failure.WithError(errorMessage); } return(failure); } return(Result.Ok()); }
public override IValidationResultCollection Validate() { ValidationResultCollection results = new ValidationResultCollection(ResourceManager); results.Add( new StringPropertyValidation( ResourceManager, Container, PropertyName ).Validate() ); return results; }
public ValidationResultCollection ValidateAttributes(ExtractedAttributes extractedAttributes) { var attributes = (ExtractedAttributes)extractedAttributes; validationResult = new ValidationResultCollection(); if (attributes.Text == "") { validationResult.Add(new MissingItem("No Interned Text")); } return(validationResult); }
/// <summary> /// Prepares the validation results for the ExceptionControl /// </summary> /// <param name="validationResults">Collection of validation results.</param> /// <param name="p">Variable no of objects.</param> public void Handle(ValidationResultCollection validationResults, params object[] p) { var results = StateManager.Personal[Key] as ValidationResultCollection; if (results != null) { results.AddRange(validationResults); } else { StateManager.Personal[Key] = validationResults; } }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "crlfPairs"); result.Passed = true; MatchCollection allLineBreaks = Regex.Matches(iCalText, @"((\r?\n)|(\r\n?))"); GC.KeepAlive(allLineBreaks); MatchCollection matches = Regex.Matches(iCalText, @"((\r(?=[^\n]))|((?<=[^\r])\n))"); if (matches.Count > 0) Warning(result, "crlfPairError"); return result; }
/// <summary> /// 验证 /// </summary> /// <param name="target"> /// 验证目标 /// </param> /// <returns> /// The <see cref="ValidationResultCollection"/>. /// </returns> public ValidationResultCollection Validate(object target) { target.CheckNull("target"); var result = new ValidationResultCollection(); var validationResults = new List<ValidationResult>(); var context = new ValidationContext(target, null, null); var isValid = System.ComponentModel.DataAnnotations.Validator.TryValidateObject(target, context, validationResults, true); if (!isValid) { result.AddResults(validationResults); } return result; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager); result.Passed = true; if (Container != null && Container.Properties != null) { bool containsProperty = false; if (PropertyNames != null) { foreach (string propName in PropertyNames) { if (Container.Properties.ContainsKey(propName)) { containsProperty = true; break; } } if (!containsProperty) { if (MinCount > 0) { Error(result, "propertyRequiredError", Container.Line, Container.Column, PropertyNames[0], ComponentName); } else if (MissingInsteadOfRequired) { Warning(result, "propertyMissingError", Container.Line, Container.Column, PropertyNames[0], ComponentName); } } else { if (MaxCount == 1 && Container.Properties.CountOf(PropertyNames[0]) > 1) { ICalendarProperty p = Container.Properties[PropertyNames[0]]; Error(result, "propertyOnlyOnceError", p.Line, p.Column, PropertyNames[0], ComponentName); } else if (Container.Properties.CountOf(PropertyNames[0]) > MaxCount) { ICalendarProperty p = Container.Properties[PropertyNames[0]]; Error(result, "propertyCountRangeError", p.Line, p.Column, PropertyNames[0], ComponentName, MinCount, MaxCount); } } } } return result; }
public ValidationResultCollection Validate() { var results = new ValidationResultCollection(); foreach (var cell in Cells) { var validatableCell = cell as IEntryCellViewModel; if (validatableCell != null) { results.AddResult(validatableCell.Validate()); } } return(results); }
protected override IValidationResultCollection ValidateProperty(ICalendarProperty p) { ValidationResultCollection result = new ValidationResultCollection(ResourceManager); if (p != null) { result.Passed = true; // Get the escaped value for this property. // This is stored during deserialization when // SerializationSettings.StoreExtraSerializationData is true. object escapedValue = p.GetService("EscapedValue"); List<string> values = new List<string>(); if (escapedValue is string) values.Add((string)escapedValue); else if (escapedValue is IList<string>) values.AddRange((IList<string>)escapedValue); // Validate the encoding EncodableDataType dt = new EncodableDataType(); dt.AssociatedObject = p; EncodableDataTypeValidation validation = new EncodableDataTypeValidation(ResourceManager, dt); result.Add(validation.Validate()); foreach (string value in values) { // Find single commas if (Regex.IsMatch(value, @"(?<!\\),")) { Error(result, "textEscapeCommasError", p.Line, p.Column, p.Name); } // Find single semicolons if (Regex.IsMatch(value, @"(?<!\\);")) { Error(result, "textEscapeSemicolonsError", p.Line, p.Column, p.Name); } // Find backslashes that are not escaped if (Regex.IsMatch(value, @"\\([^\\nN;,])")) { Error(result, "textEscapeBackslashesError", p.Line, p.Column, p.Name); } } } return result; }
public override IValidationResultCollection Validate() { ValidationResultCollection results = new ValidationResultCollection(ResourceManager); if (Container != null && Container.Properties != null) { foreach (ICalendarProperty p in Container.Properties) { if (p.Name.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase)) results.Add(ValidateProperty(p)); } } return results; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, Rule); result.Passed = true; if (Calendars != null) { foreach (IICalendar calendar in Calendars) { foreach (IEvent evt in calendar.Events) result.Add(ValidateEvent(evt)); } } return result; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager); result.Passed = true; if (Calendars != null) { foreach (IICalendar calendar in Calendars) { foreach (ICalendarObject obj in calendar.Children) result.Add(ValidateObject(obj)); } } return result; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager); if (Container.Properties.ContainsKey(PropertyName)) { ICalendarProperty p = Container.Properties[PropertyName]; string value = p.Value != null ? p.Value.ToString() : null; if (value != null && !PossibleValues.Contains(value)) { Error(result, "propertyInvalidValueWarning", p.Line, p.Column, PropertyName, ComponentName, p.Value, string.Join(", ", PossibleValues.ToArray())); } } return result; }
private void ErrorInternal( ValidationResultCollection results, string errorName, ValidationResultInfoType type, int line, int col, params object[] objects) { results.Passed = false; ValidationErrorWithLookup error = new ValidationErrorWithLookup(ResourceManager, errorName, type, line, col); error.Message = string.Format(error.Message, objects); if (error.Resolutions != null) { // Format each resolution as well. for (int i = 0; i < error.Resolutions.Length; i++) error.Resolutions[i] = string.Format(error.Resolutions[i], objects); } results.Add(error); }
protected override IValidationResultCollection ValidateObject(ICalendarObject obj) { ValidationResultCollection results = new ValidationResultCollection(ResourceManager); results.Passed = true; ICalendarPropertyListContainer c = obj as ICalendarPropertyListContainer; if (c != null) { List<string> validValues = new List<string>(new string[] { "BINARY", "BOOLEAN", "CAL-ADDRESS", "DATE", "DATE-TIME", "DURATION", "FLOAT", "INTEGER", "PERIOD", "RECUR", "TEXT", "TIME", "URI", "UTC-OFFSET" }); foreach (ICalendarProperty p in c.Properties) { foreach (ICalendarParameter parm in p.Parameters) { if (parm.Values != null && parm.Values.Length > 0 && string.Equals(parm.Name, "VALUE", StringComparison.InvariantCultureIgnoreCase)) { if (!validValues.Contains(parm.Values[0].ToUpper())) Warning(results, "unknownValueTypeParameterError", p.Line, p.Column, parm.Values[0], string.Join(", ", validValues.ToArray())); } } } } return results; }
public override IValidationResultCollection Validate() { ValidationResultCollection results = new ValidationResultCollection(ResourceManager); results.Passed = true; if (Calendars != null) { foreach (IICalendar calendar in Calendars) { results.Add(ValidationResult.GetCompositeResults( ResourceManager, "prodID", new PropertyCountValidation(ResourceManager, calendar, "VCALENDAR", "PRODID", 1, 1) )); } } return results; }
public override IValidationResultCollection Validate() { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "lineFolding"); try { StringReader sr = new StringReader(iCalText); IICalendarCollection calendar = iCalendar.LoadFromStream(sr); result.Passed = true; } catch (antlr.MismatchedTokenException ex) { if (ex.expecting == 6 && // COLON = 6 ex.mismatchType == antlr.MismatchedTokenException.TokenTypeEnum.TokenType) Fatal(result, "lineFoldingWithoutSpaceError", ex.line, ex.column, ex.Message, null); } return result; }
protected override IValidationResultCollection ValidateObject(ICalendarObject component) { ValidationResultCollection result = new ValidationResultCollection(ResourceManager, "component"); if (component is ICalendarComponent) { switch (component.Name.ToUpper()) { case "VALARM": // FIXME: VALARM should only be valid within recurring components. case "VEVENT": case "VTODO": case "VJOURNAL": case "VTIMEZONE": case "VFREEBUSY": case "DAYLIGHT": case "STANDARD": break; case "VNOTE": { Warning(result, "vnoteDeprecatedError", component.Line, component.Column); } break; default: { // FIXME: return an ERROR for nonstandard components without an "X-" prefix, and // a WARNING for "X-" components. } break; } // Validation of children of the component, for subcomponents. // This is necessary for DAYLIGHT, STANDARD, and VALARM. foreach (ICalendarObject child in component.Children) { IValidationResultCollection childResult = ValidateObject(child); if (childResult.Passed != null && childResult.Passed.HasValue && !childResult.Passed.Value) result.Add(childResult); } } return result; }
/// <summary> /// Validates the database. This returns the errors encountered by building. /// </summary> /// <param name="database">The database object to validate.</param> /// <param name="serverEdition">Edition of SQL Server to validate against (Enterprise, Standard, Developer).</param> /// <param name="results">Collection of validation results to rbe returned.</param> /// <returns>True for 'No Errors', False for 'Error Present'.</returns> public static bool ValidateDatabase(Database database, string serverEdition, out ValidationResultCollection results) { bool doesBuild = false; results = new ValidationResultCollection(); // Validate the Server Edition string if (!Enum.IsDefined(typeof(ServerEdition), serverEdition)) { throw new ArgumentException(string.Format("'{0}' is not a valid ServerEdition.", serverEdition)); } ServerEdition edition = (ServerEdition)Enum.Parse(typeof(ServerEdition), serverEdition, true); // We have to provide a ServerEdition for this method to work. There are // overloads that look like the will work without them, but they can't be used // in this scenario. // This can be modified to return warnings and messages as well. doesBuild = database.Validate(results, ValidationOptions.None, edition); return(doesBuild); }
protected override IValidationResultCollection ValidateProperty(ICalendarProperty p) { ValidationResultCollection result = new ValidationResultCollection(ResourceManager); if (p != null) { result.Passed = true; // FIXME: is it valid to have an empty URI? if (p.Value != null && !(p.Value is Uri)) { try { Uri uri = new Uri(p.Value.ToString()); Error(result, "invalidUriFormatError", p.Line, p.Column, p.Value, "An unknown error occurred."); } catch (Exception ex) { Error(result, "invalidUriFormatError", p.Line, p.Column, p.Value, ex.Message); } } } return result; }
public void Failure_Result_To_Result_Returns_Fail() { const string errorMessageA = "ErrorA"; const string errorMessageB = "ErrorB"; ValidationResultCollection result = new ValidationResultCollection(new ValidationResult[] { new ValidationResult(), new ValidationResult(new List <ValidationFailure>() { new ValidationFailure("TestA", errorMessageA) }), new ValidationResult(new List <ValidationFailure>() { new ValidationFailure("TestB", errorMessageB) }), new ValidationResult() }); Result results = result.ToResults(); Assert.True(results.IsFailed); Assert.Contains(results.Errors, r => r.Message == errorMessageA); Assert.Contains(results.Errors, r => r.Message == errorMessageB); }
public Validation() { _results = new ValidationResultCollection(); }
/// <summary> /// 处理验证错误 /// </summary> /// <param name="results">验证结果集合</param> public void Handle(ValidationResultCollection results) { }
public static JsonResultExtension ExtjsFromJsonResult(this Controller c, bool isSuccess, ValidationResultCollection ValidationResultCollection = null, List <string> msg = null) { JsonResultExtension result = new JsonResultExtension(); if (ValidationResultCollection != null && ValidationResultCollection.Count != 0) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var item in ValidationResultCollection) { dictionary.Add(item.MemberNames.First(), item.ErrorMessage); } result.Errors = dictionary; } else { result.Errors = null; } result.ExtjsUiSerialize = true; result.Success = isSuccess; string msgs = ""; if (msg != null) { foreach (var message in msg) { msgs += message + "<br/>"; } } result.Msg = msgs; return(result); }
/// <summary> /// Override this method to add imperative validation at the object level. /// </summary> /// <param name="results">A collection of the declarative validation errors. You may add and remove errors from this collection.</param> protected virtual void OnValidateObject(ValidationResultCollection results) { }
/// <summary> /// Override this method to add imperative validation at the property level. /// </summary> /// <param name="propertyName">The name of the property being validated.</param> /// <param name="results">A collection of the declarative validation errors. You may add and remove errors from this collection.</param> protected virtual void OnValidateProperty(string propertyName, ValidationResultCollection results) { }
/// <summary> /// 验证并添加到验证结果集合 /// </summary> /// <param name="results">验证结果集合</param> protected virtual void Validate(ValidationResultCollection results) { }
/// <summary> /// 处理验证结果 /// </summary> private void HandleValidationResult( ValidationResultCollection results ) { if ( results.IsValid ) return; _handler.Handle( results ); }
/// <summary> /// Initializes a new instance of the <see cref="Validator2"/> class. /// 初始化验证操作 /// </summary> public Validator2() { _result = new ValidationResultCollection(); }
partial void AttributeBasedValidation(string propertyName, ValidationResultCollection results);
protected override void ValidateCustom(ValidationResultCollection validationResults) { base.ValidateCustom(validationResults); }