mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-15 20:22:37 +08:00
Fixes #6704
This commit is contained in:
parent
03d5a375d3
commit
b8bd587a9f
@ -59,6 +59,12 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Title: "Maximum Length",
|
||||
Classes: new[] { "text", "medium" },
|
||||
Description: T("The maximum length allowed.")),
|
||||
_ValidationExpression: shape.Textbox(
|
||||
Id: "ValidationExpression",
|
||||
Name: "ValidationExpression",
|
||||
Title: "Validation Expression",
|
||||
Classes: new[] { "text", "large" },
|
||||
Description: T("The regular expression the text must match with.")),
|
||||
_CustomValidationMessage: shape.Textbox(
|
||||
Id: "CustomValidationMessage",
|
||||
Name: "CustomValidationMessage",
|
||||
|
@ -5,5 +5,6 @@ namespace Orchard.DynamicForms.Validators.Settings {
|
||||
public bool? IsRequired { get; set; }
|
||||
public int? MinimumLength { get; set; }
|
||||
public int? MaximumLength { get; set; }
|
||||
public string ValidationExpression { get; set; }
|
||||
}
|
||||
}
|
@ -23,6 +23,12 @@ namespace Orchard.DynamicForms.Validators {
|
||||
r.ErrorMessage = settings.CustomValidationMessage;
|
||||
});
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(settings.ValidationExpression)) {
|
||||
yield return _validationRuleFactory.Create<RegularExpression>(r => {
|
||||
r.Pattern = settings.ValidationExpression;
|
||||
r.ErrorMessage = settings.CustomValidationMessage;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user