public Task SaveAsync() { ValidationErrors = _advertisement.GetValidationErrors(); if (!ValidationErrors.Any()) { return(_service.AddAdvertisementAsync(_advertisement)); } return(null); }
protected virtual void Save() { IsValid = IsValid && !ValidationErrors.Any(); if (IsValid) { SetListMode(); Get(); } else { SetDetailsMode(); } }
public bool Validate() { IServiceProvider sp = TextEditor; var markerService = (TextMarkerService)sp.GetService(typeof(ITextMarkerService)); markerService.Clear(); try { ValidationErrors.Clear(); var schema = XmlSchema.Read(File.OpenText("template.xsd"), ValidateErrors); var settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings, }; settings.Schemas.Add(schema); settings.ValidationEventHandler += ValidateErrors; var tr = new XmlTextReader(TextEditor.Document.Text, XmlNodeType.Document, null); var xr = XmlReader.Create(tr, settings); while (xr.Read()) { } if (!ValidationErrors.Any()) { ErrorsRow.Height = new GridLength(0); } } catch (XmlException ex) { DisplayValidationError(ex.Message, ex.LinePosition, ex.LineNumber); } catch (Exception) { // Do Nothing } return(!ValidationErrors.Any()); }
/// <summary> /// Validates the method invocation. /// </summary> public void Validate() { CheckInitialized(); if (Parameters.IsNullOrEmpty()) { return; } if (!Method.IsPublic) { return; } if (IsValidationDisabled()) { return; } if (Parameters.Length != ParameterValues.Length) { throw new Exception("Method parameter count does not match with argument count!"); } if (ValidationErrors.Any() && HasSingleNullArgument()) { ThrowValidationError(); } for (var i = 0; i < Parameters.Length; i++) { ValidateMethodParameter(Parameters[i], ParameterValues[i]); } if (ValidationErrors.Any()) { ThrowValidationError(); } foreach (var objectToBeNormalized in ObjectsToBeNormalized) { objectToBeNormalized.Normalize(); } }
/// <summary> /// Enumerates through the <see cref="UsedSnippets" /> but will first throw an exception if there are any <see cref="MissingSnippets" />. /// </summary> public virtual IEnumerator <Snippet> GetEnumerator() { if (MissingSnippets.Any()) { throw new MissingSnippetsException(MissingSnippets); } if (MissingIncludes.Any()) { throw new MissingIncludesException(MissingIncludes); } if (ValidationErrors.Any()) { throw new ContentValidationException(ValidationErrors); } return(UsedSnippets.GetEnumerator()); }
string IDataErrorInfo.this[string columnName] { get { StringBuilder errors = new StringBuilder(); if (ValidationErrors != null && ValidationErrors.Any()) { foreach (ValidationFailure validationError in ValidationErrors) { if (validationError.PropertyName == columnName) { errors.AppendLine(validationError.ErrorMessage); } } } return(errors.ToString()); } }
public override bool IsValid() { return(!ValidationErrors.Any()); }
private bool CanSave() { return(!ValidationErrors.Any()); }
public bool IsValid() => !ValidationErrors.Any();
/// <param name="field">name of the field</param> /// <returns>Returns true if given field have error</returns> public bool HasError(string field) { return(ValidationErrors.Any(ve => ve.Field == field)); }
public void AddErrors(List <ValidationError> errors) { ValidationErrors.AddRange(errors.Where(v => !ValidationErrors.Any(e => e.ErrorMessage == v.ErrorMessage))); }