dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43073
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21899: Regex pattern validation in program rules
------------------------------------------------------------
revno: 21899
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-08 08:08:15 +0100
message:
Regex pattern validation in program rules
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2016-02-04 10:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2016-02-08 07:08:15 +0000
@@ -1300,6 +1300,7 @@
{name:"d2:round",parameters:1},
{name:"d2:hasValue",parameters:1},
{name:"d2:lastEventDate",parameters:1},
+ {name:"d2:validatePattern",parameters:2},
{name:"d2:addControlDigits",parameters:1},
{name:"d2:checkControlDigits",parameters:1}];
var continueLooping = true;
@@ -1573,6 +1574,21 @@
expression = expression.replace(callToThisFunction, valueFound);
successfulExecution = true;
}
+ else if(dhisFunction.name === "d2:validatePattern") {
+ var inputToValidate = parameters[0].toString();
+ var pattern = parameters[1];
+ var regEx = new RegExp(pattern,'g');
+ var match = inputToValidate.match(regEx);
+
+ var matchFound = false;
+ if(match !== null && inputToValidate === match[0]) {
+ matchFound = true;
+ }
+
+ //Replace the end evaluation of the dhis function:
+ expression = expression.replace(callToThisFunction, matchFound);
+ successfulExecution = true;
+ }
else if(dhisFunction.name === "d2:addControlDigits") {
var baseNumber = parameters[0];