GothenburgBitFactory / taskwarrior

Taskwarrior - Command line Task Management
https://taskwarrior.org
MIT License
4.29k stars 285 forks source link

[TW-1602] allow UDA string types to be checked for compliance with a regex #1626

Open taskwarrior opened 6 years ago

taskwarrior commented 6 years ago

Scott Mcdermott on 2015-04-25T21:07:50Z says:

Currently, for uda.foo.string we can set uda.foo.values to configure an approved list of strings.

It would be useful to support a regular expression here in addition to a list, to enforce a string format policy for a UDA (such as, all lower case values, no spaces, less than a certain length, etc, all easy with a regex). While I could enforce the policy manually for any instance of the UDA I create, a mistake/error will mean my data does not conform, and I will have to run some integrity checker manually to test all the values for compliance, before working with those data.

Suggest uda.foo.regex that could be set to a regular expression. Now Taskwarrior will disallow any set of the UDA which doesn't match the defined regular expression.

Another alternative is maybe to let uda.foo.values start with '/' or '~' and then a regex will follow, or something like this.

taskwarrior commented 6 years ago

Migrated metadata:

Created: 2015-04-25T21:07:50Z
Modified: 2017-01-16T17:32:26Z
taskwarrior commented 6 years ago

Paul Beckingham on 2015-04-25T21:58:19Z says:

Good idea.

taskwarrior commented 6 years ago

Scott Mcdermott on 2015-04-30T03:40:34Z says:

This actually might be worth generalizing to any attribute which has a string type (not just user-defined ones). For example, I would like to limit task descriptions to a certain number of characters. This is easy with e.g. ^[[:print:]]\{1,78\}$ but I'm not sure how that would be added to internal attributes.

I don't like the idea of putting all these things in add hooks because hooks could just end up being a completely parallel system with all these rules for checking things that basically are configuration. But I'm not sure that's a compelling argument. In general there is a balance, where certain things should really be available natively rather than pushed out into hooks, but it's hard to say what qualifies.

This particular kind of thing (a regex to gate adds) "feels" like configuration to me...

taskwarrior commented 6 years ago

Paul Beckingham on 2017-01-16T17:32:26Z says:

This will be addressed with the rules system.