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);
        }
Esempio n. 2
0
        public async Task SendEmail(SendEmailRequest request)
        {
            var result = validator.Validate(request);

            if (!result)
            {
                throw new ArgumentException(nameof(request));
            }
            await notificationServiceV3.SendEmail(request);
        }
Esempio n. 3
0
            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);
            }
Esempio n. 4
0
        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);
 }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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());
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
 }
Esempio n. 13
0
 /// <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));
 }
Esempio n. 14
0
 public void Validate(IObjectValidator validator)
 {
     validator.Validate(ValueWarningTwo == 2000,
                        "ValueWarningTwoMessage", ValidationTypes.Warning);
 }