Class RegexValidator
A validator that validates that the value against a regular expression.
Inheritance
Namespace: Umbraco.Cms.Core.PropertyEditors.Validators
Assembly: Umbraco.Core.dll
Syntax
public sealed class RegexValidator : IValueFormatValidator, IManifestValueValidator, IValueValidator
Constructors
View SourceRegexValidator(ILocalizedTextService)
Initializes a new instance of the Regex
Declaration
public RegexValidator(ILocalizedTextService textService)
Parameters
Type | Name | Description |
---|---|---|
ILocalized |
textService |
Remarks
Use this constructor when the validator is used as an IValue
RegexValidator(ILocalizedTextService, String)
Initializes a new instance of the Regex
Declaration
public RegexValidator(ILocalizedTextService textService, string regex)
Parameters
Type | Name | Description |
---|---|---|
ILocalized |
textService | |
System. |
regex |
Remarks
Use this constructor when the validator is used as an IValue
Properties
View SourceConfiguration
Gets or sets the configuration, when parsed as IManifest
Declaration
public string Configuration { get; set; }
Property Value
Type | Description |
---|---|
System. |
ValidationName
Gets the name of the validator.
Declaration
public string ValidationName { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
View SourceValidate(Object, String, Object)
Validates a value.
Declaration
public IEnumerable<ValidationResult> Validate(object value, string valueType, object dataTypeConfiguration)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The value to validate. |
System. |
valueType | The value type. |
System. |
dataTypeConfiguration | A datatype configuration. |
Returns
Type | Description |
---|---|
IEnumerable<System. |
Validation results. |
Remarks
The value can be a string, a Json structure (JObject, JArray...)... corresponding to what was posted by an editor.
ValidateFormat(Object, String, String)
Validates a value.
Declaration
public IEnumerable<ValidationResult> ValidateFormat(object value, string valueType, string format)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The value to validate. |
System. |
valueType | The value type. |
System. |
format | A format definition. |
Returns
Type | Description |
---|---|
IEnumerable<System. |
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.