コード例 #1
0
        public override ValidationResult Validate()
        {
            string message = _validationObject switch
            {
                CurrentClusterNodeUsageModel ext => ValidateCurrentClusterNodeUsageModel(ext),
                GetCommandTemplateParametersNameModel ext => ValidateGetCommandTemplateParametersNameModele(ext),
                _ => string.Empty
            };

            return(new ValidationResult(string.IsNullOrEmpty(message), message));
        }
コード例 #2
0
        public IActionResult GetCommandTemplateParametersName(GetCommandTemplateParametersNameModel model)
        {
            try
            {
                _logger.LogDebug($"Endpoint: \"ClusterInformation\" Method: \"GetCommandTemplateParametersName\"");
                ValidationResult validationResult = new ClusterInformationValidator(model).Validate();
                if (!validationResult.IsValid)
                {
                    ExceptionHandler.ThrowProperExternalException(new InputValidationException(validationResult.Message));
                }

                return(Ok(_service.GetCommandTemplateParametersName(model.CommandTemplateId, model.UserScriptPath, model.SessionCode)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #3
0
        private string ValidateGetCommandTemplateParametersNameModele(GetCommandTemplateParametersNameModel model)
        {
            if (model.CommandTemplateId <= 0)
            {
                _messageBuilder.AppendLine(MustBeGreaterThanZeroMessage("CommandTemplateId"));
            }

            if (ContainsIllegalCharactersForPath(model.UserScriptPath))
            {
                _messageBuilder.AppendLine("UserScriptPath contains illegal characters.");
            }

            ValidationResult sessionCodeValidation = new SessionCodeValidator(model.SessionCode).Validate();

            if (!sessionCodeValidation.IsValid)
            {
                _messageBuilder.AppendLine(sessionCodeValidation.Message);
            }
            return(_messageBuilder.ToString());
        }