On Fri, Oct 07, 2011 at 03:19:55PM -0500, John Wiegley wrote:
> >>>>> Russell Adams 
> >>>>> <RLAdams-oD4XmFtju8vuCfmLQ01/GwC/[email protected]> writes:
>
> > Through my use of Ledger, one of the issues I've noticed is that while text
> > is a powerful format, it lacks any validation. I've been plagued by a series
> > of problems caused by minor typos and had to hunt them down.
>
> > Perhaps we can add some extensions to the ledger format to allow validation?
>
> This has been suggested many times, and in fact was one of the main reasons
> that "beancount" became a fork: because I resist any and all *required*
> validation.  However, having an optional feature would be nice.  I think there
> are some Bugzilla feature requests about this, in fact.

I think that this will become an issue as the size of user ledger
files grow. Consistency is vital.

> > My first thoughts would be a directive allowed in any file which specifies
> > allowed account names, and the ability to enumerate allowed values for
> > specific TAGs. (ie: TAG X can only be X, Y or Z, or match regexp /[0-9]+/).
>
> There is an "assert" directive, allowed within automated transactions:
>
> = true
>   assert account !~ /REGEXP/ and tag =~ /REGEXP/

I'll play with that!

> You can also use "check" if you want any violations to simply be flagged as
> warnings.
>
> > Another idea would be a txn of type X, where that transaction fits a
> > "template" for lack of a better term.
>
> > I'm not sure if this would grow into the existing language, or perhaps an
> > external tool. Comments?
>
> Is the above close enough to what you need?  You could also write a validation
> function in Python, and then use the same assert above:
>
> foo.py:
>
>   def validate(post):
>        # etc., etc.
>
> foo.dat:
>
>   = true
>     assert validate(post)
>
> ledger --import foo.py -f foo.dat bal
>
> John
>

I suppose we could make a python "plugin" for validation, but I'm no
python guru.

I was already making shell & Racket scripts to just do text analysis,
but thought it was worth mentioning here to see if language support
was more suitable.


------------------------------------------------------------------
Russell Adams                            [email protected]

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

Reply via email to