using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
namespace Umbraco.Cms.Infrastructure.Runtime.RuntimeModeValidators;
///
/// Validates whether the runtime minification cache buster is not set to when in production runtime mode.
///
///
[Obsolete("Runtime minification is no longer supported, so this is no longer relevant. Will be removed entirely in V16.")]
public class RuntimeMinificationValidator : RuntimeModeProductionValidatorBase
{
private readonly IOptionsMonitor _runtimeMinificationSettings;
///
/// Initializes a new instance of the class.
///
/// The runtime minification settings.
public RuntimeMinificationValidator(IOptionsMonitor runtimeMinificationSettings)
=> _runtimeMinificationSettings = runtimeMinificationSettings;
///
protected override bool Validate([NotNullWhen(false)] out string? validationErrorMessage)
{
if (_runtimeMinificationSettings.CurrentValue.CacheBuster == RuntimeMinificationCacheBuster.Timestamp)
{
validationErrorMessage = "Runtime minification setting needs to be set to a fixed cache buster (like Version or AppDomain) in production mode.";
return false;
}
validationErrorMessage = null;
return true;
}
}