public async Task SendEmail(SendEmailRequest request) { var result = validator.Validate(request); if (!result) { throw new ArgumentException(nameof(request)); } await emailService.Send(request.FromEmail, request.ToEmail); }
public async Task SendEmail(SendEmailRequest request) { var result = validator.Validate(request); if (!result) { throw new ArgumentException(nameof(request)); } await notificationServiceV3.SendEmail(request); }
public void Validate(IObjectValidator validator) { validator.Validate(ValueThree > 500, "ValueThreeValidationMessage", ValidationTypes.Error); this.EntityValidateInvoked = true; if (this.Child != null) { validator.AddChildValidator(this.Child); } if (this.Children != null) { Children.ForEach(c => validator.AddChildValidator(c)); } validator.Validate(ValueInfoOne == 1000, "ValueWarningOne", ValidationTypes.Info); }
public void Validate(IObjectValidator validator) { validator.Validate(this.NumConnectionRetries > 0, "Number Connection Retries must be Greater than 0.", ValidationTypes.Error); if (validator.IsValid) { Connections.Select(c => validator.AddChildValidator(c)); } }
protected virtual bool AssertNestedObject(Table table, Row row, string columnName, string expected, object actual) { if (!Section.HasTable(expected)) { return(false); } parent.Validate(actual, expected); return(true); }
public IActionResult CreateForObjectValidator(string name, decimal price) { var bookDto = new CreateBookDto { Name = name, Price = price }; _objectValidator.Validate(bookDto); //var results = _objectValidator.GetErrors(bookDto); return(Ok(bookDto)); }
public ValidationResultSet Validate(object obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj), "Object to validate cannot be null."); } IObjectValidator validator = _compositeApp.CreateValidator(obj); return(validator.Validate()); }
public bool Validate(object model, string action) { IObjectValidator validator = null; for (Type type = model.GetType(); (validator == null) && (type != null); type = type.BaseType) { this.Validators.TryGetValue(type, out validator); } if (validator != null) { return(validator.Validate(model, action)); } return(true); }
public static void EnsureIsValid <T>(T argument, IObjectValidator <T> validator, string argumentName) { if (string.IsNullOrEmpty(argumentName)) { throw new ArgumentNullException("argumentName"); } if (validator == null) { throw new ArgumentNullException("validator"); } var faults = validator.Validate(argument); if (faults.Count > 0) { var message = string.Join(" ", faults.Select(x => x.Message)); throw new ArgumentException(message, argumentName); } }
public IReadOnlyCollection <ValidationResult> Validate(Token token, ITokenCollection tokenCollection) { return(_objectValidator.Validate(token, tokenCollection)); }
public IReadOnlyCollection <ValidationResult> Validate(Token token, ITokenCollection tokenCollection) { var result = _objectValidator.Validate(token, tokenCollection); return(result); }
public void Validate(IObjectValidator validator) { validator.Validate(this.CancelRequestAfterMs > 0, "Cancel Request After Milliseconds must be Greater than 0.", ValidationTypes.Error); }
/// <summary> /// Validates the supplied object to check if it can be safely used. References to invalid objects should be discarded. /// </summary> public static bool Validate(Object obj) { return(validator.Validate(obj)); }
public void Validate(IObjectValidator validator) { validator.Validate(ValueWarningTwo == 2000, "ValueWarningTwoMessage", ValidationTypes.Warning); }