Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove manifest validators #16027

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Media.EmbedProviders;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.PropertyEditors.Validators;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Snippets;
using Umbraco.Cms.Core.Strings;
Expand Down Expand Up @@ -69,13 +68,6 @@ internal static void AddAllCoreCollectionBuilders(this IUmbracoBuilder builder)
builder.DataValueReferenceFactories();
builder.PropertyValueConverters().Append(builder.TypeLoader.GetTypes<IPropertyValueConverter>());
builder.UrlSegmentProviders().Append<DefaultUrlSegmentProvider>();
builder.ManifestValueValidators()
.Add<RequiredValidator>()
.Add<RegexValidator>()
.Add<DelimitedValueValidator>()
.Add<EmailValidator>()
.Add<IntegerValidator>()
.Add<DecimalValidator>();
builder.MediaUrlGenerators();
// register OEmbed providers - no type scanning - all explicit opt-in of adding types, IEmbedProvider is not IDiscoverable
builder.EmbedProviders()
Expand Down Expand Up @@ -212,13 +204,6 @@ public static PropertyValueConverterCollectionBuilder PropertyValueConverters(th
public static UrlSegmentProviderCollectionBuilder UrlSegmentProviders(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<UrlSegmentProviderCollectionBuilder>();

/// <summary>
/// Gets the validators collection builder.
/// </summary>
/// <param name="builder">The builder.</param>
internal static ManifestValueValidatorCollectionBuilder ManifestValueValidators(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<ManifestValueValidatorCollectionBuilder>();

/// <summary>
/// Gets the content finders collection builder.
/// </summary>
Expand Down
13 changes: 0 additions & 13 deletions src/Umbraco.Core/PropertyEditors/IManifestValueValidator.cs

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ namespace Umbraco.Cms.Core.PropertyEditors.Validators;
/// <summary>
/// A validator that validates that the value is a valid decimal
/// </summary>
public sealed class DecimalValidator : IManifestValueValidator
public sealed class DecimalValidator : IValueValidator
{
/// <inheritdoc />
public string ValidationName => "Decimal";

/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(object? value, string? valueType, object? dataTypeConfiguration)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ namespace Umbraco.Cms.Core.PropertyEditors.Validators;
/// <summary>
/// A validator that validates an email address
/// </summary>
public sealed class EmailValidator : IManifestValueValidator
public sealed class EmailValidator : IValueValidator
{
/// <inheritdoc />
public string ValidationName => "Email";

/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(object? value, string? valueType, object? dataTypeConfiguration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ namespace Umbraco.Cms.Core.PropertyEditors.Validators;
/// <summary>
/// A validator that validates that the value is a valid integer
/// </summary>
public sealed class IntegerValidator : IManifestValueValidator
public sealed class IntegerValidator : IValueValidator
{
/// <inheritdoc />
public string ValidationName => "Integer";

/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(object? value, string? valueType, object? dataTypeConfiguration)
{
Expand Down
33 changes: 2 additions & 31 deletions src/Umbraco.Core/PropertyEditors/Validators/RegexValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.Validators;
/// <summary>
/// A validator that validates that the value against a regular expression.
/// </summary>
public sealed class RegexValidator : IValueFormatValidator, IManifestValueValidator
public sealed class RegexValidator : IValueFormatValidator, IValueValidator
{
private string _regex;

Expand All @@ -31,9 +31,7 @@ public RegexValidator(ILocalizedTextService textService, string regex)
/// </summary>
/// <remarks>
/// Use this constructor when the validator is used as an <see cref="IValueFormatValidator" />,
/// and the regular expression is supplied at validation time. This constructor is also used when
/// the validator is used as an <see cref="IManifestValueValidator" /> and the regular expression
/// is supplied via the <see cref="Configuration" /> method.
/// and the regular expression is supplied at validation time.
/// </remarks>
public RegexValidator()
: this(string.Empty)
Expand All @@ -50,33 +48,6 @@ public RegexValidator()
public RegexValidator(string regex)
=> _regex = regex;

/// <summary>
/// Gets or sets the configuration, when parsed as <see cref="IManifestValueValidator" />.
/// </summary>
public string Configuration
{
get => _regex;
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException(
"Value can't be empty or consist only of white-space characters.",
nameof(value));
}

_regex = value;
}
}

/// <inheritdoc cref="IManifestValueValidator.ValidationName" />
public string ValidationName => "Regex";

/// <inheritdoc cref="IValueValidator.Validate" />
public IEnumerable<ValidationResult> Validate(object? value, string? valueType, object? dataTypeConfiguration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.Validators;
/// <summary>
/// A validator that validates that the value is not null or empty (if it is a string)
/// </summary>
public sealed class RequiredValidator : IValueRequiredValidator, IManifestValueValidator
public sealed class RequiredValidator : IValueRequiredValidator, IValueValidator
{
[Obsolete($"Use the constructor that does not accept {nameof(ILocalizedTextService)}. Will be removed in V15.")]
public RequiredValidator(ILocalizedTextService textService)
Expand All @@ -19,9 +19,6 @@ public RequiredValidator()
{
}

/// <inheritdoc cref="IManifestValueValidator.ValidationName" />
public string ValidationName => "Required";

/// <inheritdoc cref="IValueValidator.Validate" />
public IEnumerable<ValidationResult> Validate(object? value, string? valueType, object? dataTypeConfiguration) =>
ValidateRequired(value, valueType);
Expand Down
Loading