← Back to team overview

dhis2-devs team mailing list archive

Re: Regular expressions in data validation rules

 

Hi Hieu,
Yes, I am actively fishing for a developer to implement this, as it
will really save me a huge amount of work in trying to clean up data.

I have no idea really how it would be implemented, other than that
java.util.regex should be able to be used, but let me give it a try at
a better specification. I do not think it should be so difficult
either.

I am thinking of something like this....

The user would create a regular expression for later assignment to a
database object. The user would select a database table (object) and
field for validation. For instance, lets say we want to validate that
there are no trailing spaces in an organization name.

So, we would create a rule called "Trailing spaces are not allowed"

We would create this rule, and assign a description and a regular
expression to it.

in this case, it would probably be something really simple like '\s+$'

Now, I have no idea how to do this in java, but I assume this would be
really simple, something like this query in Postgresql.

SELECT name from organisationunit where name ~*('\s+$')

Wow, I found 571 orgunits in my organisationunittable with trailing
spaces. Cool.

So, i think we need two objects.

1) A persistence object that stores the following files for the
RegexExpression

a) regexid
b) name
c) expression
d) description
e) resolution description (telling the user how to solve this problem)

2) A table to assign regular expressions to database objects.

a) regexid
b) table
c) field

We could maybe reuse this rule on the davavalue table, to determine if
any values have been stored with trailing spaces.

Yeah, its very easy I think. I would do it myself if I knew a lick of Java. :)

Best regards,
Jason


On Sun, Feb 7, 2010 at 7:36 PM, Hieu Dang Duy
<hieu.hispvietnam@xxxxxxxxx> wrote:
> Hi all,
>
> I've no idea about using RegEx for validating data in DHIS2. Just a small
> comment, I am also using this many times so my feeling on this is not easy
> but not too difficult when applying RegEx in your coding, ie, javascript and
> java also.
> With RegEx, we can easy controlling any thing that we want to force the user
> for entering data (text, number) or something else (a file name is an
> example).
> Let's try !
>
> Thanks !
>
> On Sun, Feb 7, 2010 at 10:24 PM, Jason Pickering
> <jason.p.pickering@xxxxxxxxx> wrote:
>>
>> https://blueprints.launchpad.net/dhis2/+spec/regex-validation
>>
>> I have updated the blueprint on regular expression use in data
>> validation rules. This would really make my life (and I suspect
>> others) lives a lot easier, as long as we are using naming
>> conventions, lets at least enforce them somehow.
>>
>> For discussion.
>>
>> Jason
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>
>
>
> --
> Hieu.HISPVietnam
> Good Health !
>



Follow ups

References