Search Results for

    Show / Hide Table of Contents
    View Source

    Class RegexValidator

    A validator that validates that the value against a regular expression.

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Core.PropertyEditors.Validators
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class RegexValidator : IValueFormatValidator, IManifestValueValidator, IValueValidator

    Constructors

    View Source

    RegexValidator(ILocalizedTextService)

    Initializes a new instance of the RegexValidator class.

    Declaration
    public RegexValidator(ILocalizedTextService textService)
    Parameters
    Type Name Description
    ILocalizedTextService textService
    Remarks

    Use this constructor when the validator is used as an IValueFormatValidator, and the regular expression is supplied at validation time. This constructor is also used when the validator is used as an IManifestValueValidator and the regular expression is supplied via the Configuration method.

    View Source

    RegexValidator(ILocalizedTextService, String)

    Initializes a new instance of the RegexValidator class.

    Declaration
    public RegexValidator(ILocalizedTextService textService, string regex)
    Parameters
    Type Name Description
    ILocalizedTextService textService
    System.String regex
    Remarks

    Use this constructor when the validator is used as an IValueValidator, and the regular expression must be supplied when the validator is created.

    Properties

    View Source

    Configuration

    Gets or sets the configuration, when parsed as IManifestValueValidator.

    Declaration
    public string Configuration { get; set; }
    Property Value
    Type Description
    System.String
    View Source

    ValidationName

    Gets the name of the validator.

    Declaration
    public string ValidationName { get; }
    Property Value
    Type Description
    System.String

    Methods

    View Source

    Validate(Object, String, Object)

    Validates a value.

    Declaration
    public IEnumerable<ValidationResult> Validate(object value, string valueType, object dataTypeConfiguration)
    Parameters
    Type Name Description
    System.Object value

    The value to validate.

    System.String valueType

    The value type.

    System.Object dataTypeConfiguration

    A datatype configuration.

    Returns
    Type Description
    IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult>

    Validation results.

    Remarks

    The value can be a string, a Json structure (JObject, JArray...)... corresponding to what was posted by an editor.

    View Source

    ValidateFormat(Object, String, String)

    Validates a value.

    Declaration
    public IEnumerable<ValidationResult> ValidateFormat(object value, string valueType, string format)
    Parameters
    Type Name Description
    System.Object value

    The value to validate.

    System.String valueType

    The value type.

    System.String format

    A format definition.

    Returns
    Type Description
    IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult>

    Validation results.

    Remarks

    The format is expected to be a valid regular expression.

    This is used to validate values against the property type validation regular expression.

    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • RegexValidator(ILocalizedTextService)
      • RegexValidator(ILocalizedTextService, String)
    • Properties
      • Configuration
      • ValidationName
    • Methods
      • Validate(Object, String, Object)
      • ValidateFormat(Object, String, String)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX