Fix errors
This commit is contained in:
@@ -7,6 +7,20 @@ namespace Umbraco.Extensions
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a service of type <typeparamref name="TService"/> with an implementation type of <typeparamref name="TImplementing"/> to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Removes all previous registrations for the type <typeparamref name="TService"/>.
|
||||
/// </remarks>
|
||||
public static void AddUnique<TService, TImplementing>(
|
||||
this IServiceCollection services)
|
||||
where TService : class
|
||||
where TImplementing : class, TService
|
||||
{
|
||||
AddUnique<TService, TImplementing>(services, ServiceLifetime.Singleton);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a service of type <typeparamref name="TService"/> with an implementation type of <typeparamref name="TImplementing"/> to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
@@ -15,7 +29,7 @@ namespace Umbraco.Extensions
|
||||
/// </remarks>
|
||||
public static void AddUnique<TService, TImplementing>(
|
||||
this IServiceCollection services,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Singleton)
|
||||
ServiceLifetime lifetime)
|
||||
where TService : class
|
||||
where TImplementing : class, TService
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
public class PropertyTypeValidation
|
||||
{
|
||||
[DataMember(Name = "mandatory")]
|
||||
public bool? Mandatory { get; set; }
|
||||
public bool Mandatory { get; set; }
|
||||
|
||||
[DataMember(Name = "mandatoryMessage")]
|
||||
public string? MandatoryMessage { get; set; }
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Umbraco.Cms.Core.Models
|
||||
/// <summary>
|
||||
/// Gets of sets a value indicating whether a value for this property type is required.
|
||||
/// </summary>
|
||||
bool? Mandatory { get; set; }
|
||||
bool Mandatory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the label of this property type should be displayed on top.
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
|
||||
dest.LabelOnTop = originalProp.PropertyType?.LabelOnTop;
|
||||
|
||||
//add the validation information
|
||||
dest.Validation.Mandatory = originalProp.PropertyType?.Mandatory;
|
||||
dest.Validation.Mandatory = originalProp.PropertyType?.Mandatory ?? false;
|
||||
dest.Validation.MandatoryMessage = originalProp.PropertyType?.MandatoryMessage;
|
||||
dest.Validation.Pattern = originalProp.PropertyType?.ValidationRegExp;
|
||||
dest.Validation.PatternMessage = originalProp.PropertyType?.ValidationRegExpMessage;
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
|
||||
target.Name = source.Label;
|
||||
target.DataTypeId = source.DataTypeId;
|
||||
target.DataTypeKey = source.DataTypeKey;
|
||||
target.Mandatory = source.Validation?.Mandatory;
|
||||
target.Mandatory = source.Validation?.Mandatory ?? false;
|
||||
target.MandatoryMessage = source.Validation?.MandatoryMessage;
|
||||
target.ValidationRegExp = source.Validation?.Pattern;
|
||||
target.ValidationRegExpMessage = source.Validation?.PatternMessage;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Models
|
||||
private Lazy<int>? _propertyGroupId;
|
||||
private string _propertyEditorAlias;
|
||||
private ValueStorageType _valueStorageType;
|
||||
private bool? _mandatory;
|
||||
private bool _mandatory;
|
||||
private string? _mandatoryMessage;
|
||||
private int _sortOrder;
|
||||
private string? _validationRegExp;
|
||||
@@ -178,7 +178,7 @@ namespace Umbraco.Cms.Core.Models
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
public bool? Mandatory
|
||||
public bool Mandatory
|
||||
{
|
||||
get => _mandatory;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _mandatory, nameof(Mandatory));
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Core.Services
|
||||
var editor = _propertyEditors[propertyType.PropertyEditorAlias];
|
||||
if (editor == null) throw new InvalidOperationException("No property editor found by alias " + propertyType.PropertyEditorAlias);
|
||||
|
||||
return ValidatePropertyValue(editor, dataType, postedValue, propertyType.Mandatory ?? false, propertyType.ValidationRegExp, propertyType.MandatoryMessage, propertyType.ValidationRegExpMessage);
|
||||
return ValidatePropertyValue(editor, dataType, postedValue, propertyType.Mandatory, propertyType.ValidationRegExp, propertyType.MandatoryMessage, propertyType.ValidationRegExpMessage);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -192,7 +192,7 @@ namespace Umbraco.Cms.Core.Services
|
||||
}
|
||||
var configuration = _dataTypeService.GetDataType(propertyType.DataTypeId).Configuration;
|
||||
var valueEditor = editor.GetValueEditor(configuration);
|
||||
return !valueEditor.Validate(value, propertyType.Mandatory ?? false, propertyType.ValidationRegExp).Any();
|
||||
return !valueEditor.Validate(value, propertyType.Mandatory, propertyType.ValidationRegExp).Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
|
||||
ContentTypeId = contentTypeId,
|
||||
DataTypeId = propertyType.DataTypeId,
|
||||
Description = propertyType.Description,
|
||||
Mandatory = propertyType.Mandatory ?? false,
|
||||
Mandatory = propertyType.Mandatory,
|
||||
MandatoryMessage = propertyType.MandatoryMessage,
|
||||
Name = propertyType.Name,
|
||||
SortOrder = propertyType.SortOrder,
|
||||
|
||||
Reference in New Issue
Block a user