Created constants for all configuration sections and used this and nameof expressions for building up configuration validation error messages.
This commit is contained in:
@@ -29,17 +29,17 @@ namespace Umbraco.Core.Configuration.Models.Validation
|
||||
|
||||
private bool ValidateMacroErrors(string value, out string message)
|
||||
{
|
||||
return ValidateStringIsOneOfEnumValues("Content:MacroErrors", value, typeof(MacroErrorBehaviour), out message);
|
||||
return ValidateStringIsOneOfEnumValues($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.MacroErrors)}", value, typeof(MacroErrorBehaviour), out message);
|
||||
}
|
||||
|
||||
private bool ValidateError404Collection(IEnumerable<ContentErrorPage> values, out string message)
|
||||
{
|
||||
return ValidateCollection("Content:Error404Collection", values, "Culture and one and only one of ContentId, ContentKey and ContentXPath must be specified for each entry", out message);
|
||||
return ValidateCollection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.Error404Collection)}", values, "Culture and one and only one of ContentId, ContentKey and ContentXPath must be specified for each entry", out message);
|
||||
}
|
||||
|
||||
private bool ValidateAutoFillImageProperties(IEnumerable<ImagingAutoFillUploadField> values, out string message)
|
||||
{
|
||||
return ValidateCollection("Content:Imaging:AutoFillImageProperties", values, "Alias, WidthFieldAlias, HeightFieldAlias, LengthFieldAlias and ExtensionFieldAlias must be specified for each entry", out message);
|
||||
return ValidateCollection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.Imaging)}:{nameof(ContentSettings.Imaging.AutoFillImageProperties)}", values, "Alias, WidthFieldAlias, HeightFieldAlias, LengthFieldAlias and ExtensionFieldAlias must be specified for each entry", out message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Configuration.Models.Validation
|
||||
|
||||
private bool ValidateSmtpSetting(SmtpSettings value, out string message)
|
||||
{
|
||||
return ValidateOptionalEntry("Global:Smtp", value, "A valid From email address is required", out message) &&
|
||||
return ValidateOptionalEntry($"{Constants.Configuration.ConfigGlobal}:{nameof(GlobalSettings.Smtp)}", value, "A valid From email address is required", out message) &&
|
||||
(value == null || ValidateStringIsOneOfEnumValues("Global:Smtp:DeliveryMethod", value.DeliveryMethod, typeof(SmtpDeliveryMethod), out message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Configuration.Models.Validation
|
||||
|
||||
private bool ValidateLocalTempStorageLocation(string value, out string message)
|
||||
{
|
||||
return ValidateStringIsOneOfEnumValues("Hosting:LocalTempStorageLocation", value, typeof(LocalTempStorage), out message);
|
||||
return ValidateStringIsOneOfEnumValues($"{Constants.Configuration.ConfigHosting}:{nameof(HostingSettings.LocalTempStorageLocation)}", value, typeof(LocalTempStorage), out message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Configuration.Models.Validation
|
||||
|
||||
private bool ValidateModelsMode(string value, out string message)
|
||||
{
|
||||
return ValidateStringIsOneOfEnumValues("ModelsBuilder:ModelsMode", value, typeof(ModelsMode), out message);
|
||||
return ValidateStringIsOneOfEnumValues($"{Constants.Configuration.ConfigModelsBuilder}:{nameof(ModelsBuilderSettings.ModelsMode)}", value, typeof(ModelsMode), out message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Configuration.Models.Validation
|
||||
private bool ValidateConvertUrlsToAscii(string value, out string message)
|
||||
{
|
||||
var validValues = new[] { "try", "true", "false" };
|
||||
return ValidateStringIsOneOfValidValues("RequestHandler:ConvertUrlsToAscii", value, validValues, out message);
|
||||
return ValidateStringIsOneOfValidValues($"{Constants.Configuration.ConfigRequestHandler}:{nameof(RequestHandlerSettings.ConvertUrlsToAscii)}", value, validValues, out message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user