/// <inheritdoc /> public void AddValidation(AbstractValidation <T> validation) { if (!Validations.Any(a => a.Name == validation.Name)) { _validations.Add(item: validation); } }
public void CreateResponseOk() { if (Validations == null || !Validations.Any()) { Message = "Success."; HttpStatusCode = (HttpStatusCode)200; } }
public bool IsHttpStatusCodeError() { if (Validations != null && Validations.Any() && (int)HttpStatusCode < 400) { CreateResponseBadRequest(); } return((int)HttpStatusCode >= 400); }
private bool ExecuteValidations(IPublishedContent content, IEnumerable <FieldWithValue> valueFields) { if (Validations != null && Validations.Any() // if any validation fails, the entire form validation fails // - instead of calling Validations.All() here, this actually forces all validations to execute && Validations.Count(v => v.IsValidFor(valueFields, content) == false) != 0) { return(false); } return(true); }
public void AddValidation(IEnumerable <ValidationMessage> validations) { var consolidateValidations = new List <ValidationMessage>(); if (Validations != null && Validations.Any()) { foreach (var validation in Validations) { consolidateValidations.Add(validation); } } consolidateValidations.AddRange(validations); Validations = consolidateValidations; }
public void AddValidation(string attribute, string message) { var validations = new List <ValidationMessage>(); if (Validations != null && Validations.Any()) { foreach (var validation in Validations) { validations.Add(validation); } } validations.Add(new ValidationMessage { Attribute = attribute, Message = message }); Validations = validations; }
/// <summary> /// Retorna a mensagem e possíveis validações do result. /// </summary> /// <returns></returns> public override string ToString() { var sb = new StringBuilder(); sb.Append(Message); if (!Valid && Validations != null && Validations.Any()) { sb.AppendLine(""); Validations.ForEach(val => sb.AppendLine($"- {val.Attribute}: {val.Message}")); } string toString = sb.ToString(); if (toString.EndsWith("\r\n")) { toString = toString.Substring(0, toString.Length - 2); } return(toString); }
public void ValidateAndThrow() { AddValidattions(); if (dations.Count > 0) { message = dations.Message; } if (!String.IsNullOrEmpty(message)) { if (dations.Any(a => a.CustomException != null && !a.Ok)) { var err = dations.First(a => a.CustomException != null && !a.Ok); throw err.CustomException; } else { throw new ValidationException(message); } } }
public string SimpleMessage() { string mensaje = string.Empty; if (Validations.Any()) { foreach (Validation validation in Validations) { mensaje += validation.Message; mensaje += "\n"; } } if (Errors.Any()) { foreach (string error in Errors) { mensaje += error; mensaje += "\n"; } } return(mensaje); }
public bool HasValidatedTheme(int roundNumber, string theme) => Validations.Any(v => v.RoundNumber == roundNumber && v.Theme.Equals(theme));
public override bool IsValid() => !Validations.Any();