예제 #1
0
        /// <inheritdoc/>
        public CommandValidationResult Validate(CommandRequest command)
        {
            var result          = new CommandValidationResult();
            var commandInstance = _commandRequestConverter.Convert(command);

            var validationResults = ValidateInternal(commandInstance);

            result.ValidationResults    = validationResults.Where(v => v.MemberNames.First() != ModelRule <object> .ModelRulePropertyName);
            result.CommandErrorMessages = validationResults.Where(v => v.MemberNames.First() == ModelRule <object> .ModelRulePropertyName).Select(v => v.ErrorMessage);
            return(result);
        }
        /// <inheritdoc/>
        public CommandValidationResult Validate(CommandRequest command)
        {
            var errorMessages     = new List <string>();
            var validationResults = new List <ValidationResult>();

            foreach (var validator in _validators)
            {
                var validatorResult = validator.Validate(command);
                errorMessages.AddRange(validatorResult.CommandErrorMessages);
                validationResults.AddRange(validatorResult.ValidationResults);
            }

            var result = new CommandValidationResult
            {
                CommandErrorMessages = errorMessages,
                ValidationResults    = validationResults
            };

            return(result);
        }