/// <summary> /// /// </summary> /// <param name="entity"></param> protected override void OnValidate(CodeSnippet entity) { base.OnValidate(entity); bool isNew = entity.tstamp == null; if (string.IsNullOrEmpty(entity.Code)) { ValidationErrors.Add("Code snippet must be provided", "Code"); } else if (entity.Code.Length > App.Configuration.MaxCodeLength) { ValidationErrors.AddFormat("Code snippet length cannot exceed {0:n0} bytes. Your's is: {1:n0} bytes.", "Code", "Code", App.Configuration.MaxCodeLength, entity.Code.Length); } //if (string.IsNullOrEmpty(entity.Title)) // this.ValidationErrors.Add("Please provide a title for the snippet", "Title"); if (entity.Tags != null && (entity.Tags.Contains("./") || entity.Tags.Contains(".\\"))) { ValidationErrors.Add("Tags cannot contain path related characters", "Tags"); } if (string.IsNullOrEmpty(entity.Language)) { ValidationErrors.Add("Please provide a code language or NoFormat for no formatting", "Language"); } if (isNew && !string.IsNullOrEmpty(entity.Code)) { if (EntityExists(entity)) { ValidationErrors.Add("Snippet exists already", "Code"); } } if (IsSpam(entity)) { ValidationErrors.Add("Invalid entry", "Code"); } }