Issue #116: Add RegEx validation support
Add RegEx validation for the individual properties in a fieldset as proposed in issue #116
This commit is contained in:
@@ -30,6 +30,9 @@ namespace Archetype.Models
|
||||
public string Value { get; set; }
|
||||
|
||||
[JsonProperty("required")]
|
||||
public bool Required { get; set; }
|
||||
public bool Required { get; set; }
|
||||
|
||||
[JsonProperty("regEx")]
|
||||
public bool RegEx { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -97,10 +97,22 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
property.isValid = true;
|
||||
|
||||
var propertyConfig = getPropertyByAlias(configFieldsetModel, property.alias);
|
||||
if(propertyConfig && propertyConfig.required && (property.value == null || property.value === "")){
|
||||
fieldset.isValid = false;
|
||||
property.isValid = false;
|
||||
valid = false;
|
||||
if (propertyConfig) {
|
||||
if(propertyConfig.required && (property.value == null || property.value === "")) {
|
||||
fieldset.isValid = false;
|
||||
property.isValid = false;
|
||||
valid = false;
|
||||
}
|
||||
// issue 116: RegEx validate property value
|
||||
// Only validate the property value if anything has been entered - RegEx is considered a supplement to "required".
|
||||
if (valid == true && propertyConfig.regEx && property.value) {
|
||||
var regEx = new RegExp(propertyConfig.regEx);
|
||||
if (regEx.test(property.value) == false) {
|
||||
fieldset.isValid = false;
|
||||
property.isValid = false;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Standard værdi",
|
||||
"dataType": "Datatype",
|
||||
"required": "Påkrævet",
|
||||
"regEx": "RegEx validering",
|
||||
"properties": "Egenskaber",
|
||||
"labelTemplate": "Label skabelon",
|
||||
"select": "Vælg",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
<label for="archetypePropertyRequired_{{$parent.$index}}_{{$index}}"><archetype-localize key="required">Required</archetype-localize></label>
|
||||
<input type="checkbox" id="archetypePropertyRequired_{{$parent.$index}}_{{$index}}" ng-model="property.required" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="archetypePropertyRegEx_{{$parent.$index}}_{{$index}}"><archetype-localize key="regEx">RegEx Validation</archetype-localize></label>
|
||||
<input type="text" id="archetypePropertyRegExValue_{{$parent.$index}}_{{$index}}" ng-model="property.regEx" />
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user