using System.ComponentModel.DataAnnotations; using System.Xml.Linq; using Umbraco.Cms.Core.Models.Editors; using Umbraco.Cms.Core.PropertyEditors; namespace Umbraco.Cms.Core.Models; /// /// Represents an editor for editing data values. /// /// This is the base interface for parameter and property value editors. public interface IDataValueEditor { /// /// Gets the editor view. /// string? View { get; } /// /// Gets the type of the value. /// /// The value has to be a valid value. string ValueType { get; set; } /// /// Gets a value indicating whether the edited value is read-only. /// bool IsReadOnly { get; } /// /// Gets a value indicating whether to display the associated label. /// bool HideLabel { get; } /// /// Gets a value indicating whether the IDataValueEditor supports readonly mode /// bool SupportsReadOnly => false; /// /// Gets the validators to use to validate the edited value. /// /// /// Use this property to add validators, not to validate. Use instead. /// TODO: replace with AddValidator? WithValidator? /// List Validators { get; } /// /// Validates a property value. /// /// The property value. /// A value indicating whether the property value is required. /// A specific format (regex) that the property value must respect. IEnumerable Validate(object? value, bool required, string? format); /// /// Converts a value posted by the editor to a property value. /// object? FromEditor(ContentPropertyData editorValue, object? currentValue); /// /// Converts a property value to a value for the editor. /// object? ToEditor(IProperty property, string? culture = null, string? segment = null); // TODO: / deal with this when unplugging the xml cache // why property vs propertyType? services should be injected! etc... /// /// Used for serializing an item for packaging /// /// /// /// IEnumerable ConvertDbToXml(IProperty property, bool published); /// /// Used for serializing an item for packaging /// /// /// /// XNode ConvertDbToXml(IPropertyType propertyType, object value); string ConvertDbToString(IPropertyType propertyType, object? value); }